Skip to content

pg.table.size exclude TOAST, but pg.table.discovery exclude TOAST too #150

Description

@triwada

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions