Converts a regular PostgreSQL table into a TimescaleDB hypertable that automatically creates and manages time-series partitions, called chunks or child tables. section 9.4
SELECT create_hypertable(
relation => 'watch.heart_rate_measurements',
dimension => by_range('recorded_at', interval '1 month'),
create_default_indexes => false
);
Run this statement to partition heart-rate measurements by one-month ranges on recorded_at while disabling default index creation. section 9.4
Configure the function through three parameters:
- Set relation to the table being converted, such as watch.heart_rate_measurements. section 9.4
- Set dimension to a range partition over recorded_at, using a one-month interval. section 9.4
- Set create_default_indexes to false when planning indexes separately for time-series workloads. section 9.4
- Choose partition granularity carefully: monthly chunks suit a small dataset but may be too large for millions of devices. section 9.4
Verify automatic chunk creation
Inspect the converted table to list child tables, then insert a row beyond the current range. TimescaleDB creates a new chunk covering the next one-month interval. section 9.4
