Created
September 16, 2024 09:11
-
-
Save elliotcm/000a3d092a158902c9c4f07624ea8eae to your computer and use it in GitHub Desktop.
PostgreSQL: 10 biggest tables by disk size, plus a row count estimate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with row_counts as (SELECT reltuples, relname FROM pg_class) | |
select | |
table_name, | |
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))) as total_size, | |
row_counts.reltuples::decimal(38,0) as row_count | |
from information_schema.tables | |
join row_counts on table_name = row_counts.relname | |
where table_schema = 'public' | |
order by pg_total_relation_size(quote_ident(table_name)) desc | |
limit 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment