Add more handy SQL snippets

pull/12/head
Urban Guacamole 4 years ago
parent 1f9b37b724
commit 49fae72182

@ -14,4 +14,13 @@ CREATE MATERIALIZED VIEW fresh AS
max(leechers) AS l,
max(completed) AS c
FROM trackerdata
GROUP BY infohash;
GROUP BY infohash;
--- size of table
SELECT pg_size_pretty(pg_total_relation_size('"<schema>"."<table>"'));
--- count rows
SELECT reltuples::bigint AS estimate FROM pg_class where relname='mytable';
--- create fulltext table
CREATE TABLE search AS select torrent.*, fresh.s as s, fresh.l as l, to_tsvector(torrent.name) as vect from torrent inner join fresh on fresh.infohash = torrent.infohash;
Loading…
Cancel
Save