Sample Header Ad - 728x90

Difference between total table size and size of all pages in postgresql

2 votes
1 answer
1666 views
Working with Postgres I noticed the following: When I run this query I get the total table size: SELECT pg_size_pretty( pg_table_size('tenk1') ); I get 384kb. And when I run: SELECT relpages FROM pg_class WHERE relname = 'tenk1'; I get 45 pages. I know that one page has 8kb. I confirmed that with SELECT current_setting('block_size'); Therefore, my table size should be 45 * 8kB = 360kB, instead of 384kb. Where does the difference of 24kb come from? What else could take up this space? I know that indexes are excluded by pg_table_size. But its TOAST table if any, free space map, and visibility map are included. Is there a way to determine their sizes?
Asked by Piet Pro
Mar 27, 2023, 03:06 PM
Last activity: Mar 28, 2023, 09:13 PM