Skip to main content
Old API since v2.18.0. Replaced by chunk_columnstore_stats(). Get -specific statistics related to compression. All sizes are in bytes. This function shows the compressed size of s, computed when the compress_chunk is manually executed, or when a compression policy processes the . An insert into a compressed does not update the compressed sizes. For more information about how to compute sizes, see the chunks_detailed_size section.

Samples

SELECT * FROM chunk_compression_stats('conditions')
  ORDER BY chunk_name LIMIT 2;

-[ RECORD 1 ]------------------+----------------------
chunk_schema                   | _timescaledb_internal
chunk_name                     | _hyper_1_1_chunk
compression_status             | Uncompressed
before_compression_table_bytes |
before_compression_index_bytes |
before_compression_toast_bytes |
before_compression_total_bytes |
after_compression_table_bytes  |
after_compression_index_bytes  |
after_compression_toast_bytes  |
after_compression_total_bytes  |
node_name                      |
-[ RECORD 2 ]------------------+----------------------
chunk_schema                   | _timescaledb_internal
chunk_name                     | _hyper_1_2_chunk
compression_status             | Compressed
before_compression_table_bytes | 8192
before_compression_index_bytes | 32768
before_compression_toast_bytes | 0
before_compression_total_bytes | 40960
after_compression_table_bytes  | 8192
after_compression_index_bytes  | 32768
after_compression_toast_bytes  | 8192
after_compression_total_bytes  | 49152
node_name                      |
Use pg_size_pretty get the output in a more human friendly format.
SELECT pg_size_pretty(after_compression_total_bytes) AS total
  FROM chunk_compression_stats('conditions')
  WHERE compression_status = 'Compressed';

-[ RECORD 1 ]--+------
total | 48 kB

Arguments

NameTypeDefaultRequiredDescription
hypertableREGCLASS-Name of the

Returns

ColumnTypeDescription
chunk_schemaTEXTSchema name of the
chunk_nameTEXTName of the
compression_statusTEXTthe current compression status of the
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 is located, applicable only to distributed s