libzbxpgsql
libzbxpgsql copied to clipboard
pg.table.size exclude TOAST, but pg.table.discovery exclude TOAST too
pg.table.discovery exclude TOAST tables from search, and item "pg.table.size" not include TOAST size. In some cases the most consumed space of table will be in TOAST. For example, table "images" from Zabbix database
select
n.nspname AS schema
,c.relname
,c.reltuples
,c.relpages
,c.relkind
,pg_relation_size(c.oid) AS relation_size
,pg_indexes_size(c.oid) AS index_size
,pg_total_relation_size(reltoastrelid) AS toast_size
,pg_total_relation_size(c.oid) AS total_relataion_size
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema','pg_toast') and pg_total_relation_size(reltoastrelid)>8192;
schema | relname | reltuples | relpages | relkind | relation_size | index_size | toast_size | total_relataion_size
--------+---------+-----------+----------+---------+---------------+------------+------------+----------------------
public | images | 187 | 10 | r | 81920 | 32768 | 1073152 | 1212416
(1 row)
At this case pg.table.size collect only 81920, but in fact table consume more space