Hypertables offer the following benefits:
- Efficient data management with automated partitioning by time: TimescaleDB splits your data into chunks that hold data from a specific time range. For example, one day or one week. You can configure this range to better suit your needs.
- Better performance with strategic indexing: an index on time in the descending order is automatically created when you create a hypertable. More indexes are created on the chunk level, to optimize performance. You can create additional indexes, including unique indexes, on the columns you need.
- Faster queries with chunk skipping: TimescaleDB skips the chunks that are irrelevant in the context of your query, dramatically reducing the time and resources needed to fetch results. Even more—you can enable chunk skipping on non-partitioning columns.
- Advanced data analysis with hyperfunctions: TimescaleDB enables you to efficiently process, aggregate, and analyze significant volumes of data while maintaining high performance.
Inheritance is not supported for hypertables and may lead to unexpected behavior.
Create a hypertable
To create a hypertable for your time-series data, useCREATE TABLE. For efficient queries on data in
the columnstore, remember to segmentby the column you will use most often to filter your data. For example:
compress_after in the
policy. This columnar format enables fast scanning and
aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the
columnstore conversion, hypertable chunks are compressed by up to 98%, and organized for efficient, large-scale queries.
You can customize this policy later using alter_job. However, to change after or
created_before, the compression settings, or the hypertable the policy is acting on, you must
remove the columnstore policy and add a new one.
You can also manually convert chunks in a hypertable to the columnstore.
For TimescaleDB v2.23.0 and higher, the table is automatically partitioned on the first column
in the table with a timestamp data type. If multiple columns are suitable candidates as a partitioning column,
TimescaleDB throws an error and asks for an explicit definition. For earlier versions, set
partition_column to a
time column.If you are self-hosting TimescaleDB v2.20.0 to v2.22.1, to convert your
data to the columnstore after a specific time interval, you have to call add_columnstore_policy after you call
CREATE TABLEIf you are self-hosting TimescaleDB v2.19.3 and below, create a Postgres relational table,
then convert it using create_hypertable. You then enable hypercore with a call
to ALTER TABLE.Samples
Create a hypertable
Create a hypertable using theCREATE TABLE syntax with hypercore for optimal performance:
Drop old chunks
Remove chunks older than 3 months to manage storage:View chunk information
Get detailed information about chunks for a hypertable:Add a space dimension
Add a second partitioning dimension for multi-dimensional data:Available functions
Table creation
CREATE TABLE: create a hypertable using standard SQL syntax with hypercore
Chunk management
show_chunks(): display chunks associated with hypertablesdrop_chunks(): remove chunks from hypertablesmove_chunk(): move a chunk to a different tablespacereorder_chunk(): reorder a single chunk by an indexmerge_chunks(): merge multiple chunks into a single chunksplit_chunk(): split a chunk into multiple chunksattach_chunk(): attach a table as a chunk to a hypertabledetach_chunk(): detach a chunk from a hypertableset_chunk_time_interval(): set the time interval for chunk creationset_integer_now_func(): set function to compute current time for integer-based times
Dimension management
add_dimension(): add a space-partitioning dimension to a hypertable
Size and statistics
hypertable_size(): get the total disk space used by a hypertablehypertable_detailed_size(): get detailed disk space usage for a hypertablehypertable_index_size(): get the total size of indexes on a hypertablehypertable_approximate_size(): get an approximate total size of a hypertablehypertable_approximate_detailed_size(): get approximate detailed size informationchunks_detailed_size(): get detailed size information for chunks
Tablespace management
attach_tablespace(): attach a tablespace to a hypertabledetach_tablespace(): detach a tablespace from a hypertabledetach_tablespaces(): detach all tablespaces from a hypertableshow_tablespaces(): show tablespaces attached to a hypertable
Reordering and policies
add_reorder_policy(): add a policy to automatically reorder chunksremove_reorder_policy(): remove an automatic chunk reordering policy
Query optimization
enable_chunk_skipping(): enable chunk skipping for a hypertabledisable_chunk_skipping(): disable chunk skipping for a hypertable
Legacy functions
For backward compatibility, TimescaleDB also providescreate_hypertable(), which was the
original function for creating hypertables. Use CREATE TABLE for new hypertables.