Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Postgres Reverse ETL Setup


Set up Postgres as your Reverse ETL source.

At a high level, when you set up Postgres for Reverse ETL, the configured user/role needs read permissions for any resources (databases, schemas, tables) the query needs to access. Segment keeps track of changes to your query results with a managed schema (__SEGMENT_REVERSE_ETL), which requires the configured user to allow write permissions for that schema.

(information)

Postgres Reverse ETL sources support Segment's dbt extension

If you have an existing dbt account with a Git repository, you can use Segment's dbt extension to centralize model management and versioning, reduce redundancies, and run CI checks to prevent breaking changes.

Segment supports the following Postgres database providers:

  • Heroku
  • RDS
(warning)

Warning

Segment only supports these Postgres database providers. Postgres databases from other providers aren't guaranteed to work. For questions or concerns about Segment-supported Postgres providers, contact Segment Support(link takes you to an external page).


Set up guide

set-up-guide page anchor

To set up Postgres with Reverse ETL:

  1. Log in to your Postgres account.

  2. Configure the correction network and security settings for your Postgres database.

  3. Run the SQL commands below to create a user named segment.

    1
    -- create a user named "segment" that Segment will use when connecting to your Postgres cluster.
    2
    CREATE USER segment PASSWORD '<enter password here>';
    3
    4
    -- allows the "segment" user to create new schemas on the specified database. (this is the name you chose when provisioning your cluster)
    5
    GRANT CREATE ON DATABASE "<enter database name here>" TO "segment";
    6
    7
    -- create Segment schema
    8
    CREATE SCHEMA __segment_reverse_etl;
    9
    10
    -- Allow user to use the Segment schema
    11
    GRANT USAGE ON SCHEMA __segment_reverse_etl TO segment;
    12
    13
    -- Grant all privileges on all existing tables in the Segment schema
    14
    GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA __segment_reverse_etl TO segment;
  4. Make sure the user has correct access permissions to the database.

  5. Follow the steps listed in the Add a source section to finish adding Postgres as a source.


  • Give the segment user read permissions for any resources (databases, schemas, tables) the query needs to access.
  • Give the segment user write permissions for the Segment managed schema (__SEGMENT_REVERSE_ETL), which keeps track of changes to the query results.

After you've successfully added your Postgres source, add a model and follow the rest of the steps in the Reverse ETL setup guide.

How to use the same user for a Postgres destination and Reverse ETL source

how-to-use-the-same-user-for-a-postgres-destination-and-reverse-etl-source page anchor

If you're using the same database user for both a Segment Postgres warehouse destination (where Segment writes data into Postgres) and Reverse ETL source (where Segment reads data from Postgres), make sure the user has:

  • SELECT or READ access on all source tables for Reverse ETL
  • CREATE SCHEMA __SEGMENT_REVERSE_ETL permission (or ability to use an existing schema)
  • INSERT, UPDATE, and DELETE permissions on tables within __SEGMENT_REVERSE_ETL