hypertable_detailed_size()

Get detailed information about disk space used by a hypertable, returning size information for the table itself, any indexes on the table, any toast tables, and the total size of all. All sizes are reported in bytes. If the function is executed on a distributed hypertable, it returns size information as a separate row per node, including the access node.

Required Arguments

NameTypeDescription
hypertableREGCLASSHypertable to show detailed size of.

Returns

ColumnTypeDescription
table_bytesBIGINTDisk space used by main_table (like pg_relation_size(main_table))
index_bytesBIGINTDisk space used by indexes
toast_bytesBIGINTDisk space of toast tables
total_bytesBIGINTTotal disk space used by the specified table, including all indexes and TOAST data
node_nameTEXTFor distributed hypertables, this is the user-given name of the node for which the size is reported. NULL is returned for the access node and non-distributed hypertables.

tip

If executed on a relation that is not a hypertable, the function returns NULL.

Sample Usage

Get size information for a hypertable.

  1. -- disttable is a distributed hypertable --
  2. SELECT * FROM hypertable_detailed_size('disttable') ORDER BY node_name;
  3. table_bytes | index_bytes | toast_bytes | total_bytes | node_name
  4. -------------+-------------+-------------+-------------+-------------
  5. 16384 | 40960 | 0 | 57344 | data_node_1
  6. 8192 | 24576 | 0 | 32768 | data_node_2
  7. 0 | 8192 | 0 | 8192 |

The access node is listed without a user-given node name. Normally, the access node holds no data, but still maintains, e.g., index information that occupies a small amount of disk space.