From c9c830256315066afdc619eeaba5b234de89468e Mon Sep 17 00:00:00 2001
From: Bryan Newbold <bnewbold@robocracy.org>
Date: Tue, 21 May 2019 12:04:07 -0700
Subject: commit SQL table stats scripts

---
 extra/sql_dumps/stats_table_size.sql | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 extra/sql_dumps/stats_table_size.sql

(limited to 'extra/sql_dumps/stats_table_size.sql')

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;
-- 
cgit v1.2.3

