hypertable_compression_stats()

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

Required arguments

Name Type Description
hypertable REGCLASS Hypertable to show stats for.

Returns

Column Type Description
total_chunks BIGINT the number of chunks used by the hypertable
number_compressed_chunks INTEGER the number of chunks used by the hypertable that are currently compressed
before_compression_table_bytes BIGINT Size of the heap before compression (NULL if currently uncompressed)
before_compression_index_bytes BIGINT Size of all the indexes before compression (NULL if currently uncompressed)
before_compression_toast_bytes BIGINT Size the TOAST table before compression (NULL if currently uncompressed)
before_compression_total_bytes BIGINT Size of the entire table (table+indexes+toast) before compression (NULL if currently uncompressed)
after_compression_table_bytes BIGINT Size of the heap after compression (NULL if currently uncompressed)
after_compression_index_bytes BIGINT Size of all the indexes after compression (NULL if currently uncompressed)
after_compression_toast_bytes BIGINT Size the TOAST table after compression (NULL if currently uncompressed)
after_compression_total_bytes BIGINT Size of the entire table (table+indexes+toast) after compression (NULL if currently uncompressed)
node_name TEXT nodes on which the hypertable is located, applicable only to distributed hypertables

Sample usage

2. SELECT * FROM hypertable_compression_stats('conditions');

4. -[ RECORD 1 ]------------------+------

6. total_chunks                   | 4

8. number_compressed_chunks       | 1

10. before_compression_table_bytes | 8192

12. before_compression_index_bytes | 32768

14. before_compression_toast_bytes | 0

16. before_compression_total_bytes | 40960

18. after_compression_table_bytes  | 8192

20. after_compression_index_bytes  | 32768

22. after_compression_toast_bytes  | 8192

24. after_compression_total_bytes  | 49152

26. node_name                      |

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

2. SELECT pg_size_pretty(after_compression_total_bytes) as total

4. FROM hypertable_compression_stats('conditions');

6. -[ RECORD 1 ]--+------

8. total | 48 kB