You can migrate data into a Timescale hypertable from a regular PostgreSQL table. This method assumes that you have Timescale set up in the same database instance as your existing table.

Before beginning, make sure you have installed and set up Timescale.

You also need a table with existing data. In this example, the source table is named old_table. Replace the table name with your actual table name. The example also names the destination table new_table, but you might want to use a more descriptive name.

Migrate your data into Timescale from within the same database.

  1. Create a new table based on your existing table. You can create your indexes at the same time, so you don't have to recreate them manually. Or you can create the table without indexes, which makes data migration faster.

    CREATE TABLE new_table (
  2. Convert the new table to a hypertable using the create_hypertable function. Replace ts with the name of the column that holds time values in your table.

    SELECT create_hypertable('new_table', by_range('ts'));

    The by_range dimension builder is an addition to TimescaleDB 2.13.

  3. Insert data from the old table to the new table.

    INSERT INTO new_table
    SELECT * FROM old_table;
  4. If you created your new table without indexes, recreate your indexes now.


Found an issue on this page?Report an issue or Edit this page in GitHub.