hypertable_compression_stats()

Get statistics related to hypertable compression. All sizes are in bytes.

Required arguments

NameTypeDescription
hypertableREGCLASSHypertable to show stats for.

Returns

ColumnTypeDescription
total_chunksBIGINTthe number of chunks used by the hypertable
number_compressed_chunksINTEGERthe number of chunks used by the hypertable that are currently compressed
before_compression_table_bytesBIGINTSize of the heap before compression (NULL if currently uncompressed)
before_compression_index_bytesBIGINTSize of all the indexes before compression (NULL if currently uncompressed)
before_compression_toast_bytesBIGINTSize the TOAST table before compression (NULL if currently uncompressed)
before_compression_total_bytesBIGINTSize of the entire table (table+indexes+toast) before compression (NULL if currently uncompressed)
after_compression_table_bytesBIGINTSize of the heap after compression (NULL if currently uncompressed)
after_compression_index_bytesBIGINTSize of all the indexes after compression (NULL if currently uncompressed)
after_compression_toast_bytesBIGINTSize the TOAST table after compression (NULL if currently uncompressed)
after_compression_total_bytesBIGINTSize of the entire table (table+indexes+toast) after compression (NULL if currently uncompressed)
node_nameTEXTnodes on which the hypertable is located, applicable only to distributed hypertables

Sample usage

  1. SELECT * FROM hypertable_compression_stats('conditions');
  2. -[ RECORD 1 ]------------------+------
  3. total_chunks | 4
  4. number_compressed_chunks | 1
  5. before_compression_table_bytes | 8192
  6. before_compression_index_bytes | 32768
  7. before_compression_toast_bytes | 0
  8. before_compression_total_bytes | 40960
  9. after_compression_table_bytes | 8192
  10. after_compression_index_bytes | 32768
  11. after_compression_toast_bytes | 8192
  12. after_compression_total_bytes | 49152
  13. node_name |

Use pg_size_pretty get the output in a more human friendly format.

  1. SELECT pg_size_pretty(after_compression_total_bytes) as total
  2. FROM hypertable_compression_stats('conditions');
  3. -[ RECORD 1 ]--+------
  4. total | 48 kB