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.
First connect to the PostgreSQL instance:
# Connect to PostgreSQL, using a superuser named 'postgres'
psql -U postgres -h localhost
Now create a new empty database (skip this if you already have a database):
-- Create the database, let's call it 'tutorial'
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:
-- Connect to the database
\c tutorial
-- Extend the database with TimescaleDB
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:
psql -U postgres -h localhost -d tutorial
From here, you will create a TimescaleDB hypertable using one of the following options:
- Start from scratch: You don’t currently have any data, and just want to create an empty hypertable for inserting data.
- Migrate from PostgreSQL: You are currently storing time-series data in a PostgreSQL database, and want to move this data to a TimescaleDB hypertable.