Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Destinations

PostgreSQL

Configure PostgreSQL as a destination in Artie, including host and port, service account, schema ownership and DB permissions.

Create a service account

Run these commands in your Postgres client as a database admin. They create the user Artie connects with and let it create schemas.

SQL
-- Create the service account if it doesn't exist yet
CREATE USER artie WITH PASSWORD 'PASSWORD';

-- Grant create on the database, so the service account creates schemas as needed
GRANT CREATE ON DATABASE DATABASE_NAME TO artie;

-- If the schema exists, change the owner to the service account.
-- DDL operations such as ALTER TABLE or DROP TABLE are restricted to the owner.
ALTER SCHEMA SCHEMA_NAME OWNER TO artie;

Replace PASSWORD with the user’s password and DATABASE_NAME with the database Artie writes to. Run the ALTER SCHEMA statement once for each existing schema Artie writes to, replacing SCHEMA_NAME.

The service account needs CREATE on the database and must own every schema Artie writes to.

To connect Databricks Lakebase without password logins, follow Databricks Lakebase and connect with OAuth instead.

Required settings

Enter the connection fields on the destination connector, then choose the database and schema on your pipeline’s destination.

FieldDefaultValue
HostNoneThe IP address or host name of your database, for example server.example.com.
Port5432The port PostgreSQL listens on, from 1 to 65535.
Authentication methodPasswordPassword, or Databricks Lakebase OAuth for Databricks Lakebase.
UserNoneWith Password authentication, the service account user, for example artie.
PasswordNoneWith Password authentication, the service account password.
Database nameNoneThe database Artie writes your tables to.
Schema nameNoneThe schema Artie writes to. Select one, or type a new name and select Create “NAME”.

Schema layout

When your source has schemas, choose One schema or Multiple schemas. The pipeline page labels them Write to one schema and Write to multiple schemas.

One schema sends every table to the schema in Schema name. For source tables outside the default schema, Artie prepends the source schema name to the destination table name.

Multiple schemas sends each table to a schema with the same name as its source schema, and Schema name isn’t used. To add a prefix to each schema name, set Schema name prefix (optional).

On a running pipeline, the schema fields are locked. Pause the pipeline to change them, then move its tables to the new schema in your destination. For how Artie names tables in each layout, see Destination table naming.

Network access

Artie reaches your database through an SSH tunnel, an IP allowlist, or PrivateLink. Connection options describes each method.

Add PostgreSQL to a pipeline

The pipeline setup reaches the destination after you choose your tables.

  1. Choose the destination

    On Choose your destination, select PostgreSQL.

  2. Choose network access

    On How would you like to connect your destination?, select SSH tunnel, Allowlist Artie IPs, or PrivateLink.

  3. Prepare the database

    On Prepare your PostgreSQL account, run the service account commands, then select Continue.

  4. Enter the settings

    On Connect PostgreSQL, fill in the required settings.

  5. Verify the destination

    Select Verify destination. The step shows Destination verified.

  6. Continue

    Select Continue.

To check the destination later, select Verify later. If you haven’t chosen tables yet, the button reads Test connection and checks only the connection.

When you pick a PostgreSQL connector that other pipelines use, the setup marks the network access and preparation steps as done and skips them. Connect PostgreSQL shows the connector’s details in place of the connection fields, and you still set the database and schema.

Advanced features

These destination settings apply to PostgreSQL. All three are off by default.

SettingLabel on the pipeline pageWhat it does
Staging schemaPut staging tables in a different schemaKeeps Artie’s temporary staging tables in a separate schema from the one your tables land in.
Create missing schemasDynamically create namespacesCreates destination schemas that don’t exist yet when the pipeline deploys.
Mirror source partitionsMirror source partitionsTurns on partition mirroring. Shown only when the source is PostgreSQL.

In the pipeline setup, open Advanced options on the Connect PostgreSQL step. On an existing pipeline, select Edit pipeline, open the Destination: PostgreSQL tab, and go to Advanced settings.

Partition mirroring

Partition mirroring creates each partitioned PostgreSQL source table as a partitioned destination table with the same partitions. Artie writes to the parent table, and PostgreSQL routes each row to its partition.

It requires a PostgreSQL source. Turn on Mirror source partitions in the destination’s advanced settings. The setting sits under Data types in the pipeline setup and under Data handling on the pipeline page. Then add the partitioned parent table, not its individual partitions.

When it runs

Artie mirrors partitions at three points.

WhenWhat Artie does
Every deploy, including new tables, backfills, and resumed pipelinesCreates the destination parent table and any missing partitions before Artie writes data.
Daily, 7:00–8:00 AM Pacific TimeCreates destination partitions for source partitions added since the last run. This runs with automatic schema changes, so it requires them to be enabled and only covers running pipelines.
When you request a check through the APIDoes the same as the daily run, for the pipelines you request.

When the daily run or an API check creates partitions, Artie sends the automatic schema changes email. The email lists the created tables and the CREATE TABLE statements Artie ran.

If a table that is about to be backfilled can’t be fully created, the deploy fails and the backfill doesn’t start. The deploy also fails when a partitioned source table has no destination parent table and Artie can’t create one.

Without a deploy or an API check, Artie mirrors new source partitions once a day. Create them at least a day before rows arrive, for example with pg_partman’s premake.

Key behaviors

  • Supports RANGE, LIST, and HASH partitions, DEFAULT partitions, and sub-partitions.
  • Runs CREATE TABLE IF NOT EXISTS, one table per transaction, with a 5-second lock timeout and a 1-minute statement timeout.
  • Creates a partition that times out waiting for a lock on the next run.
  • Creates the source’s enum types in the destination schema before it creates a parent table that uses them.
  • Creates every partition in the destination table’s schema.
  • Never detaches, drops, renames, truncates, or moves rows. If you detach, split, merge, or rename source partitions, update the destination manually.
  • If a backfill is set to drop the destination table first, Artie truncates it instead, so the partitions stay in place.
  • Doesn’t convert an existing unpartitioned destination table. The deploy fails if that table is about to be backfilled.
  • Leaves history tables unpartitioned.

Rows that arrive before their partition exists

Without a DEFAULT partition, the write fails and Artie retries it until the partition is created.

With a DEFAULT partition, the row lands in the default partition. Artie can’t create the new partition until you move those rows out of the default partition.

Tables Artie can’t mirror

Artie can’t mirror these tables:

  • A partition replicated on its own instead of through its parent.
  • Foreign-table partitions.
  • Tables unified across schemas.
  • Tables or partitions whose destination name is longer than 63 bytes.
  • Tables whose partition key columns have uppercase letters or special characters, because Artie lowercases destination column names.

Next steps

Was this page helpful?