Unexpected Query Planner Behavior in TimescaleDB

Hi everyone,

I recently encountered an issue where TimescaleDB’s query planner is not using an index I created on a hypertable. The table contains millions of rows & I expected my queries to benefit from indexing, but EXPLAIN ANALYZE shows that the planner is opting for a sequential scan instead. :upside_down_face:

I hav checked index type (e.g., B-tree vs. BRIN) to ensure it’s suitable for my query patterns.

Ran ANALYZE and VACUUM to update statistics. Forced index usage using SET enable_seqscan TO off; which speeds up the query, but I don’t want to rely on manual overrides. :thinking:
Checked Timescale Documentation | Troubleshooting queriesMlops Course guide related to this and found it quite informative.

Has anyone else faced this issue? Could it be related to TimescaleDB’s chunking mechanism affecting query planning? Any insights on why PostgreSQL/TimescaleDB might ignore an index even when it seems optimal? :thinking:

Thank you!! :slightly_smiling_face:

It can happen if the table is very small, then it may use sequential scan.

Can you share your query and explain analyze output?