Skip to content

Commit b50318f

Browse files
committed
chore: Adds devops script for getting table sizes
1 parent 1ce7df3 commit b50318f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

scripts/get-table-storage-sizes.sql

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SELECT
2+
table_name,
3+
pg_size_pretty (table_size) AS table_size,
4+
pg_size_pretty (indexes_size) AS indexes_size,
5+
pg_size_pretty (total_size) AS total_size
6+
FROM
7+
(
8+
SELECT
9+
table_name,
10+
pg_table_size (table_name) AS table_size,
11+
pg_indexes_size (table_name) AS indexes_size,
12+
pg_total_relation_size (table_name) AS total_size
13+
FROM
14+
(
15+
SELECT
16+
('"' || table_schema || '"."' || table_name || '"') AS table_name
17+
FROM
18+
information_schema.tables
19+
) AS all_tables
20+
ORDER BY
21+
total_size DESC
22+
) AS pretty_sizes;

0 commit comments

Comments
 (0)