Postgresql – Find Uncompressed/Compressed Sizes of TimescaleDB Database/Table

compressionpostgresqltimescaledb

For a database/table in TimescaleDB and PostgreSQL 11 running on ZFS with both ZFS compression and native TimescaleDB compression enabled, how can you find the uncompressed and compressed sizes when

  1. using native TimescaleDB compression and ZFS compression
  2. using native TimescaleDB compression but not ZFS compression
  3. not using native TimescaleDB compression and using ZFS compression
  4. not using native TimescaleDB compression and not using ZFS compression

I want to use these values to find out the compress ratio due to TimescaleDB native compression and due to ZFS

Best Answer

If you want to find out savings from TimescaleDB's native compression, use this information view for the hypertable: https://docs.timescale.com/latest/api#timescaledb_information-compressed_chunk_stats

In the field, we're typically seeing seeing 90-98% storing savings across a large numbers of users.

For measuring ZFS, look at the numbers returned by zfs get compression and zfs get compressratio (see, e.g., https://www.servethehome.com/the-case-for-using-zfs-compression/)

If you are running native compression on top, you'll see that this is the amount of compression that ZFS adds on top of TimescaleDB's native compression. Would love to hear what you see; would expect that to actually be pretty minimal (or even negative).