I am trying to find the distinct values of a column from a table. According to the article from blog-post by timescale, skipscan is the way to go for these type of queries because they are much more optimized. However, the query takes forever to run on our db and eventually times out.
Table details:
Table "ts_data"
ts : timestamp with time zone, not null
sensor_id : uuid, not null
value : numeric
Indexes:
"ts_data_pkey" PRIMARY KEY, btree (sensor_id, ts)
"ts_data_sensor_id" btree (sensor_id)
"ts_data_ts_idx" btree (ts DESC)
Triggers:
ts_insert_blocker BEFORE INSERT ON ts_data FOR EACH ROW EXECUTE PROCEDURE _timescaledb_internal.insert_blocker()
Number of child tables: 448
Query being used: select distinct on (sensor_id) * from ts_data;
Query Explain details: Explain-depesz
Postgres version: PostgreSQL 11.12
Timescale version: 2.3.1