Hi! It was updated TimescaleDB to 2.16.0 on PG 15.2. I planned to check FK to hypertable but focused with situation that I cannot make hypertable to be compressed.
Here the script to reproduce:
DROP TABLE IF EXISTS ref_hyper;
CREATE TABLE ref_hyper(
id NUMERIC,
col1 TEXT,
modify_date TIMESTAMP,
PRIMARY KEY (id, modify_date)
);
SELECT * FROM create_hypertable(
relation => 'ref_hyper',
dimension => by_range('modify_date')
);
ALTER TABLE ref_hyper
SET
(
timescaledb.compress,
timescaledb.compress_orderby = 'id'
);
Output:
SQL Error [42601]: ERROR: cannot use column "id" for both ordering and segmenting
HINT: Use separate columns for the timescaledb.compress_orderby and timescaledb.compress_segmentby options.
Does this mean that it is now mandatory to specify the compress_segmentby?
If to switch on only compression then “id” used by default for segmentby_column although it is not required:
ALTER TABLE ref_hyper SET(timescaledb.compress);
Table timescaledb_information.compression_settings
:
hypertable_name|attname |segmentby_column_index|orderby_column_index|orderby_asc|orderby_nullsfirst|
---------------+-----------+----------------------+--------------------+-----------+------------------+
ref_hyper |id | 1| | | |
ref_hyper |modify_date| | 1|false |true |
Then I tried to add empty compress_segmentby
and then compression was applied with needed params:
ALTER TABLE ref_hyper
SET
(
timescaledb.compress,
timescaledb.compress_orderby = 'id',
timescaledb.compress_segmentby = ''
);
Table timescaledb_information.compression_settings
:
hypertable_name|attname |segmentby_column_index|orderby_column_index|orderby_asc|orderby_nullsfirst|
---------------+-----------+----------------------+--------------------+-----------+------------------+
ref_hyper |id | | 1|true |false |
ref_hyper |modify_date| | 2|false |true |