Skip to content

Instantly share code, notes, and snippets.

@hatarist
hatarist / pg_get_table_sizes.sql
Created September 8, 2017 15:48
PostgreSQL: get table size (data & index & toast)
View pg_get_table_sizes.sql
SELECT
*,
pg_size_pretty(table_bytes) AS table,
pg_size_pretty(index_bytes) AS index,
pg_size_pretty(total_bytes) AS total
FROM (
SELECT
*, total_bytes - index_bytes - COALESCE(toast_bytes, 0) AS table_bytes
FROM (
SELECT