1

One of the tables in my Postgresql database takes up 25 GB and I want to understand which columns contribute to this size. I suspect that there are 2 columns (both columns allow text with no chars limit) that contribute heavily to the table size. I checked each of the column sizes by using the query below, but their size doesnt add up to 25 GB..Can someone advise me on how I can see the split of 25 GB by column?

select pg_size_pretty(sum(pg_column_size(insert_column_name))) as total_size from insert_table_name

I suspect the above query is giving me the wrong size taken up by each column in the table, because all the individual column sizes add up to only 4-5 GB (when it should add to 25 GB).

  1. Where is the remaining shortfall of 20GB coming from if the query above is correct?
  2. Can you advise on what query I can use to see the split of 25GB by columns?
abby99914
  • 11
  • 1
  • 1
    From where did you get the value of 25GB when you don't ask it above the database? Have you see this value in the windows explorer when you checked the folder size of the folder with the name *data*? Once in the past I hade this problem that the size of the database was incresed, because the folder with log files has take a lot of space. – kanukiesel May 09 '20 at 19:17
  • https://www.compose.com/articles/postgresql-bloat-origins-monitoring-and-managing/ – Abelisto May 09 '20 at 19:24
  • 1
    Does this answer your question? [How do you find the disk size of a Postgres / PostgreSQL table and its indexes](https://stackoverflow.com/questions/2596624/how-do-you-find-the-disk-size-of-a-postgres-postgresql-table-and-its-indexes) – Schwern May 09 '20 at 19:28

0 Answers0