Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Rails Support
      • Working with Bundler
    • Python
      • Working with Django
      • Background Jobs in Python
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Databases & Data Management
  • Heroku Postgres
  • Postgres Basics
  • Heroku Postgres

Heroku Postgres

English — 日本語に切り替える

Last updated August 11, 2023

Table of Contents

  • Understanding Heroku Postgres Plans
  • Provisioning Heroku Postgres
  • Local Setup
  • Designating a Primary Database
  • Sharing Heroku Postgres Between Applications
  • Version Support
  • Performance Analytics
  • Using the CLI
  • Connecting to Heroku Postgres
  • Migrating between Plans
  • Data Residency
  • Removing the Add-on
  • Support

Heroku Postgres is a managed SQL database service provided directly by Heroku. You can access a Heroku Postgres database from any language with a PostgreSQL driver, including all languages officially supported by Heroku.

Heroku Postgres Dashboard

In addition to a variety of Heroku CLI commands to manage your database, Heroku Postgres provides a web dashboard, dataclips to share queries, and several other helpful features.

Understanding Heroku Postgres Plans

Heroku Postgres offers a variety of plans, spread across different tiers of service: Essential, Standard, Premium, Private, and Shield. For more information on what each plan provides, see Choosing the Right Heroku Postgres Plan.

Pricing information for Heroku Postgres plans is available on the Heroku Postgres add-on page.

If your app’s requirements eventually outgrow the resources provided by the initial plan you select, you can easily upgrade your database.

Provisioning Heroku Postgres

For more information about how to provision a Heroku Postgres database, see Provisioning Heroku Postgres.

Local Setup

Heroku recommends running Postgres locally to ensure parity between environments. For more information about how to set up Heroku Postgres to run in your local environment, see Local Setup for Heroku Postgres.

Designating a Primary Database

The DATABASE_URL config var designates the URL of an app’s primary Heroku Postgres database. For apps with a single database, its URL is automatically assigned to this config var.

For apps with multiple Postgres databases, set the primary database with heroku pg:promote. Common use cases include leader-follower high-availability setups or as part of the database upgrade process.

Sharing Heroku Postgres Between Applications

You can share a single Heroku Postgres database between multiple apps with the heroku addons:attach command:

$ heroku addons:attach my-originating-app::DATABASE --app example-app
Attaching postgresql-addon-name to example-app... done
Setting HEROKU_POSTGRESQL_BRONZE vars and restarting example-app... done, v11

The attached database’s URL is assigned to a config var with the name format HEROKU_POSTGRESQL_[COLOR]_URL. In the example, the config var’s name is HEROKU_POSTGRESQL_BRONZE_URL.

A shared database isn’t necessarily the primary database for any given app that it’s shared with. To promote a shared database, use the same command that you use for any other database.

To stop sharing your Heroku Postgres instance with another app, use the heroku addons:detach command:

$ heroku addons:detach HEROKU_POSTGRESQL_BRONZE --app example-app
Detaching HEROKU_POSTGRESQL_BRONZE to postgresql-addon-name from example-app... done
Unsetting HEROKU_POSTGRESQL_BRONZE config vars and restarting example-app... done, v11

Version Support

The PostgreSQL project releases new major versions on a yearly basis. Heroku Postgres supports each major version shortly after its release. For more information about version support on Heroku Postgres, see Heroku Postgres Version Support.

Performance Analytics

For more information about performance analytics, see Heroku Postgres Performance Analytics.

Using the CLI

For more information about managing Heroku Postgres using the CLI, see Managing Heroku Postgres Using the CLI.

Connecting to Heroku Postgres

For more information about connecting to Heroku Postgres, see Connecting to Heroku Postgres.

Migrating between Plans

See this detailed guide on updating and migrating between database plans.

Data Residency

When a database gets provisioned, the data associated with that database is stored within the region in which it’s created. However, some services ancillary to Heroku Postgres and the systems managing the database fleet aren’t located within the same region as the provisioned databases:

  • Postgres Continuous Protection for disaster recovery stores the base backup and write-ahead logs in the same region that the database is located.
  • Logs for the Common Runtime are routed in the same region the app is running within. For example, logs for an app in the us region gets routed through the us infrastructure.
  • Logs for apps in Private Spaces stay within the same region as the space itself. For example, logs for an app in a Tokyo space routes through the infrastructure in Tokyo. You can deploy apps with strict compliance requirements in Shield Private Spaces, which uses Private Space Logging to route logs instead of Logplex.
  • Logging of Heroku Postgres queries and errors can be blocked by using the --block-logs flag when creating the database with heroku addons:create heroku-postgres:....
  • PG Backup snapshots are stored in the US. To capture logical backups in another region, see Heroku Postgres Logical Backups.
  • Dataclips are stored in the US.

See the Salesforce Infrastructure & Sub-processors document for the list of sub-processors Heroku uses and the list of countries where Heroku data is stored and processed.

Blocking Logs

At add-on creation time, you can pass a flag to prevent logging of queries that get run against the database. If this option is turned on, it can’t be turned off after the database has been provisioned. To turn it off after it has been turned on, a migration to a new database is required.

Blocking the queries in the logs reduces Heroku’s ability to help debug applications and tune application performance.

$ heroku addons:create heroku-postgresql:standard-0 -a example-app --block-logs

Removing the Add-on

To remove your Heroku Postgres database, you must destroy the add-on:

$ heroku addons:destroy heroku-postgresql

If you have two databases of the same type you must remove the add-on using its config var name. For example, to remove the HEROKU_POSTGRESQL_GRAY_URL database, run the command:

$ heroku addons:destroy HEROKU_POSTGRESQL_GRAY

If the removed database was the same one used in DATABASE_URL, that DATABASE_URL config var is unset on the app.

Databases can’t be reconstituted after being destroyed. Take a snapshot of the data beforehand using PG Backups or by exporting the data.

Support

Submit all Heroku Postgres support and runtime issues via one of the Heroku Support channels.

Keep reading

  • Postgres Basics

Feedback

Log in to submit feedback.

Upgrading the Version of a Heroku Postgres Database Heroku Postgres Credentials

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany
  • heroku.com
  • Terms of Service
  • Privacy (日本語)
  • Cookies
  • Cookie Preferences
  • Your Privacy Choices
  • © 2023 Salesforce.com