Create a hypertable

Creating a hypertable is a two-step process.

  1. Create a standard table ([PostgreSQL docs][postgres-createtable]).

    1. CREATE TABLE conditions (
    2. time TIMESTAMPTZ NOT NULL,
    3. location TEXT NOT NULL,
    4. temperature DOUBLE PRECISION NULL
    5. );
  2. Execute the TimescaleDB create_hypertable command on this newly created table, or use create_distributed_hypertable to create a distributed hypertable that scales out across multiple data nodes.

    1. SELECT create_hypertable('conditions', 'time');

If you need to migrate data from an existing table to a hypertable, make sure to set the migrate_data argument to true when calling the function. If you would like finer control over index formation and other aspects of your hypertable, follow these migration instructions instead.

warning

The use of the migrate_data argument to convert a non-empty table can lock the table for a significant amount of time, depending on how much data is in the table.

tip

The ‘time’ column used in the create_hypertable function supports timestamp, date, or integer types, so you can use a parameter that is not explicitly time-based, as long as it can increment. For example, a monotonically increasing id would work.