Setup

Ok, you haveinstalled TimescaleDB, and now you are ready to work with some data. The first thing to do is to create a new empty database or convert an existing PostgreSQL database to use TimescaleDB.

TIP:If you are planning on doing any performance testing on TimescaleDB, we strongly recommend that youconfigure TimescaleDB properly.

setup illustration

First connect to the PostgreSQL instance:

  1. # Connect to PostgreSQL, using a superuser named 'postgres'
  2. psql -U postgres -h localhost

Now create a new empty database (skip this if you already have a database):

  1. -- Create the database, let's call it 'tutorial'
  2. CREATE database tutorial;

WARNING:Starting in v0.12.0, TimescaleDB enablestelemetry reporting by default. You can opt-out by following the instructions detailed in ourtelemetry documentation. However, please do note that telemetry is anonymous, and by keeping it on, you help usimprove our product.

Lastly add TimescaleDB:

  1. -- Connect to the database
  2. \c tutorial
  3. -- Extend the database with TimescaleDB
  4. CREATE EXTENSION IF NOT EXISTS timescaledb;

TIP:If you want to install a version that is not the most recent available on your system you can specify the version like so:CREATE EXTENSION timescaledb VERSION '1.7.4';

That’s it! Connecting to the new database is as simple as:

  1. psql -U postgres -h localhost -d tutorial

From here, you will create a TimescaleDB hypertable using one of the following options:

  1. Start from scratch: You don’t currently have any data, and just want to create an empty hypertable for inserting data.
  2. Migrate from PostgreSQL: You are currently storing time-series data in a PostgreSQL database, and want to move this data to a TimescaleDB hypertable.