postgresql

PostgreSQL table size


I created a table using the like option

(like prod_events including all ) 

No records were inserted. The table prod_events does have indexes and a JSONB column. When I executed the query -

select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) as total_size,
pg_relation_size(relid) as data_size,
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid))
  as external_size
from pg_catalog.pg_statio_user_tables
order by pg_total_relation_size(relid) desc,
         pg_relation_size(relid) desc
limit 10;

The newly created table has data_size of 0, but total_size/external_size of 32 KB. What would explain that? PostgreSQL Version is 13.15


Solution

  • There are probably four indexes, each of which has a meta-page of 8kB, even if the index is empty.