Setting up TimescaleDB
If you don’t have a TimescaleDB instance yet, you can set one up using Docker:Enable logical replication
To determine if logical replication is already enabled for your TimescaleDB instance, you can run the following SQL command:logical
. If it doesn’t, you’ll need to enable it by setting wal_level
to logical
.
Enabling replication requires a restart of your database.
1
Configure WAL level
Connect to your TimescaleDB container and edit the PostgreSQL configuration:
You can also find the location of your
postgresql.conf
file by running the SQL command show config_file;
.Provision a Postgres user for Sequin
When in development, it’s probably fine to supply Sequin with an existing user. However, when in production, you should create a dedicated user for Sequin. The user needs the following permissions:connect
permission on the database.select
permission on all the tables you want to connect to Sequin.replication
permission to read from replication slots.
Connect Sequin to your TimescaleDB database
After enabling logical replication, you’ll now connect to your database in Sequin:1
Enter connection details in Sequin
In the Sequin Console, click on the “Connect Database” button and enter the credentials for your TimescaleDB database:
- Host: Your TimescaleDB host (e.g.,
localhost
or your Docker machine IP) - Port: 5432 (default Postgres port)
- Database: Your database name
- Username: The sequin database user you created earlier
- Password: The password for your sequin database user
2
Create a publication
Connect to your database using the SQL client of your choice and execute one of the following SQL queries to create a publication:
When using TimescaleDB, there are important considerations for publications:
- Using
FOR ALL TABLES
is the most reliable approach, though it requires more resources - If you need to publish specific tables, you must include both:
- The schema containing your base tables (usually
public
) - The TimescaleDB internal schema (
_timescaledb_internal
)
- The schema containing your base tables (usually
- Avoid using
FOR TABLE table_name
with TimescaleDB hypertables, as this can cause replication to stop when new chunks are created
For either approach, you can further limit which tables are replicated with table filtering in Sequin instead.
3
Create a replication slot
Next, create a replication slot to capture changes from the publication:
4
Enter the replication slot details in Sequin
Back in the Sequin Console, enter the name of the replication slot (e.g.
sequin_slot
) and publication (e.g. sequin_pub
) you just created. Then, name your database and click “Create Database”.Create a sink
With your TimescaleDB database connected to Sequin, you are ready to create a sink. Follow one of our guides below to get started:Stream to Webhooks
Send database changes to your HTTP endpoints to trigger workflows and keep services in sync
Stream to Redis Streams
Stream changes to Redis Streams for real-time data processing and caching
Stream to Kafka
Publish database changes to Kafka topics for event streaming and processing
Stream to SQS
Send changes to AWS SQS queues to trigger Lambda functions and other AWS services