Docs
PostgreSQL

PostgreSQL

Amazon Redshift redirects here

Postgres is a great default choice for a database engine. It's a general purpose engine that wasn't designed specifically for analytics purposes, but is often fast enough to start with and can scale surprisingly well, especially if you have someone caring for and tuning your installation.

A benefit of its popularity is that there are easy and cheap providers of server-less instances, such as Heroku (opens in a new tab) and Neon (opens in a new tab). Additionally, there are other databases that are PostgreSQL compatible, such as Redshift, CockroachDB or Timescale. If you're using one of these databases, you can use our PostgreSQL connection type to connect to your database.

If you're looking to get started an existing application database, querying your production database isn't ideal. We have a full write up on how to get started with a read replica:

Performance

If you're starting off with a copy of your application database, there's a high chance you'll end up writing a query to join, transform, and filter data to prepare it for Glean as a denormalized table. It's worth checking which version of PostgreSQL you're on to see what transformation functions are available to you. Also, try to take advantage of indexes to keep queries fast.

How to get set up

  1. We recommend creating a separate user for Glean (opens in a new tab) to use in order to easily track usage and performance.
  2. Grant the user the appropriate roles (opens in a new tab) needed to query your analytics data.
  3. Set up a connection in Glean:
    1. First, go to your Glean settings (opens in a new tab) page from the project dropdown.
    2. Click + New Database Connection and fill out the fields below.

Settings

  • Connection Name: A nickname for your connection. Not used to connect to your database.
  • Host: The address of your PostgreSQL database.
  • Port: The open port of your Postgres host, it is often 5432.
  • Username: The username.
  • Password: The password.
  • Database: The name of the database (opens in a new tab) to read from.
  • Schema: (optional) Specify a schema to limit which tables are available. Otherwise, Glean will make all accessible schemas and tables available.