From 49fae721827bf0274e894e1aff59038b759f1d84 Mon Sep 17 00:00:00 2001 From: Urban Guacamole Date: Mon, 23 Dec 2019 20:33:46 +0100 Subject: [PATCH] Add more handy SQL snippets --- snippets.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/snippets.sql b/snippets.sql index 9cfb1a5..62e09b1 100644 --- a/snippets.sql +++ b/snippets.sql @@ -14,4 +14,13 @@ CREATE MATERIALIZED VIEW fresh AS max(leechers) AS l, max(completed) AS c FROM trackerdata - GROUP BY infohash; \ No newline at end of file + GROUP BY infohash; + +--- size of table +SELECT pg_size_pretty(pg_total_relation_size('"".""')); + +--- 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; \ No newline at end of file