]> gitweb.pimeys.fr Git - scripts-20-100.git/commitdiff
Hint SQL sur comment trouver la taille qu'occupent les INDEX
authorVincent Le Gallic <legallic@crans.org>
Fri, 12 Feb 2016 00:23:56 +0000 (01:23 +0100)
committerVincent Le Gallic <legallic@crans.org>
Fri, 12 Feb 2016 00:24:18 +0000 (01:24 +0100)
pg_size_of_indexes.sql [new file with mode: 0644]

diff --git a/pg_size_of_indexes.sql b/pg_size_of_indexes.sql
new file mode 100644 (file)
index 0000000..5b9ed44
--- /dev/null
@@ -0,0 +1,8 @@
+SELECT nspname || '.' || relname AS "relation",
+    pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
+  FROM pg_class C
+  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
+  WHERE nspname NOT IN ('pg_catalog', 'information_schema')
+    AND C.relkind = 'i'
+    AND nspname !~ '^pg_toast'
+  ORDER BY pg_total_relation_size(C.oid) DESC;