summaryrefslogtreecommitdiffstats
path: root/extra/sql_dumps/stats_table_size.sql
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-21 12:04:07 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-21 12:04:07 -0700
commitc9c830256315066afdc619eeaba5b234de89468e (patch)
tree97a41b61aef01b6bb8e99459fba884436a6a52a1 /extra/sql_dumps/stats_table_size.sql
parente14e039c4c0ccbc0db3c58cd71c09e8c3146f6fe (diff)
downloadfatcat-c9c830256315066afdc619eeaba5b234de89468e.tar.gz
fatcat-c9c830256315066afdc619eeaba5b234de89468e.zip
commit SQL table stats scripts
Diffstat (limited to 'extra/sql_dumps/stats_table_size.sql')
-rw-r--r--extra/sql_dumps/stats_table_size.sql17
1 files changed, 17 insertions, 0 deletions
diff --git a/extra/sql_dumps/stats_table_size.sql b/extra/sql_dumps/stats_table_size.sql
new file mode 100644
index 00000000..cb8da26d
--- /dev/null
+++ b/extra/sql_dumps/stats_table_size.sql
@@ -0,0 +1,17 @@
+SELECT
+ table_name,
+ pg_size_pretty(table_size) AS table_size,
+ pg_size_pretty(indexes_size) AS indexes_size,
+ pg_size_pretty(total_size) AS total_size
+ FROM (
+ SELECT
+ table_name,
+ pg_table_size(table_name) AS table_size,
+ pg_indexes_size(table_name) AS indexes_size,
+ pg_total_relation_size(table_name) AS total_size
+ FROM (
+ SELECT ('"' || table_schema || '"."' || table_name || '"') AS table_name
+ FROM information_schema.tables
+ ) AS all_tables
+ ORDER BY total_size DESC
+ ) AS pretty_sizes;