postgresqltimescaledbhypertable

Custom Indexes on TimeScaleDB Hypertable


I'm using a TimeScaleDB and PostgreSQL to manage timeseries data.

When optimizing the table is it recommended to rely purely on TimeScaleDB hypertable or should I also add indexes independently the same way I would do when not using a hypertable?

What is critical in that scenario is the performance of retrieving the data.


Solution

  • TimescaleDB creates an index on the time dimension by default. If your queries often select data on values from other columns, it can be helpful to create indexes on such columns as you would do with normal tables. However, in the case of TimescaleDB all indexes should be compound and include the time dimension column. You might drop the automatically created index on the time dimension after you created new indexes. As usual creating new indexes should take in consideration that indexes occupy additional space and require more processing resources to maintain them.

    Timescale has a blog post, which has advises on adding indexes.