I have a big table on my database, but it has a lot of empty fields on every column, and I´d like to know how much does every column use.
Is there any way to know how much disk space is each tables columns using?
Try using pg_column_size(), it will return the column size in bytes:
SELECT sum(pg_column_size(column)) FROM yourtable
As the documentation mentions, NULL values are indicated in the null bitmap of every tuple, which is always present if the table has nullable columns.
So a NULL value consumes no extra space on disk.
If you design tables with very many columns, rethink your design.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With