Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • 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
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • 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 PGSettings

Heroku PGSettings

English — 日本語に切り替える

Last updated February 18, 2025

Table of Contents

  • log-lock-waits
  • log-min-duration-statement
  • log-min-error-statement
  • log-statement
  • track-functions
  • pg-replication-slot-logs
  • auto-explain

Heroku Postgres non-legacy Standard, Premium, Private, and Shield plans can manage database settings by configuring parameters via the pg:settings command.

$ heroku pg:settings postgresql-large-1234 -a example-app
=== postgresql-large-1234
log-lock-waits:                     true
log-min-duration-statement:         2000
log-min-error-statement:            error
log-statement:                      ddl
track-functions:                    pl
pg-replication-slot-logs:           off
auto-explain:                       true
auto-explain.log-analyze:           false
auto-explain.log-buffers:           false
auto-explain.log-format:            text
auto-explain.log-min-duration:      200
auto-explain.log-nested-statements: false
auto-explain.log-triggers:          false
auto-explain.log-verbose:           false

Essential-tier plans include the default settings, which you can’t reconfigure.

log-lock-waits

log-lock-waits determines whether a log message is produced when a session waits longer than 1 second to acquire a lock. Lock waits can cause performance issues. The default value in Heroku Postgres is on.

$ heroku pg:settings:log-lock-waits postgresql-large-1234 off -a example-app
log-lock-waits has been set to false for postgresql-large-1234.
When a deadlock is detected, no log message will be emitted in your application's logs.

log-min-duration-statement

log-min-duration-statement logs the duration of each completed statement if the statement ran for at least the specified number of milliseconds. A value of 0 logs everything and a value of -1 disables logging. This setting can help you track down unoptimized queries in your applications. The default value of log-min-duration-statement in Heroku Postgres is set to 2000 milliseconds (2 seconds).

In a system with hundreds of queries executing every second, log files can grow quickly and hamper database performance.

$ heroku pg:settings:log-min-duration-statement postgresql-large-1234 3000 -a example-app
log-min-duration-statement has been set to 3000 for postgresql-large-1234.

log-min-error-statement

log_min_error_statement controls the logging of SQL statements that cause an error at a specified severity level. Use this setting to prevent logging SQL queries that contain sensitive information. The valid values for log_min_error_statement are:

  • error
  • log
  • fatal
  • panic

The default value is error.

Only panic errors log the SQL statement.

$ heroku pg:settings:log-min-error-statement postgresql-large-1234 panic -a example-app

log-statement

log-statement controls which normal SQL statements are logged. This setting can help you debug complex queries or review queries made by your app or any database user. Valid values for log-statement are:

  • none: Stops logging normal queries. Other logs still generate such as slow query logs, queries waiting in locks, and syntax errors
  • ddl: Log all data definition statements, such as CREATE, ALTER, and DROP.
  • mod: Includes all statements from ddl as well as data-modifying statements such as INSERT, UPDATE, DELETE, TRUNCATE, and COPY.
  • all: Log all statements.

The default value of log-statement in Heroku Postgres is ddl.

$ heroku pg:settings:log-statement postgresql-large-1234 all -a example-app
log-statement has been set to all for postgresql-large-1234.

track-functions

track-functions determines which functions have their execution statistics tracked. These statistics can be found in the pg_stat_user_functions view. Valid values for track-functions are:

  • none: No function statistics are recorded.
  • pl: Procedural language function statistics are recorded (for example, PL/pgSQL functions).
  • all: All functions, including SQL and C language function statics are recorded.

This default value is none.

$ heroku pg:settings:track-functions postgresql-large-1234 pl -a example-app
track-functions has been set to pl for postgresql-large-1234.
Track only procedural-language functions.

pg-replication-slot-logs

pg-replication-slot-logs displays stats on replication slots on your database. See Heroku Postgres Metrics Logs for the list of metrics. The default value is off.

$ heroku pg:settings:pg-replication-slot-logs postgresql-large-1234 on -a example-app

auto-explain

auto_explain logs query execution plans automatically without having to run EXPLAIN by hand. Running auto-explain can help identify queries that run slowly and can help you understand how to optimize your database’s performance. Enable auto_explain with:

$ heroku pg:settings:auto-explain postgresql-large-1234 on -a example-app

Enabling auto_explain can cause performance impacts and a significant increase in log volume so use with caution and monitor your database performance. auto-explain enables the module for all future Heroku Postgres connections. Existing connections must be reestablished before auto_explain logging occurs.

auto-explain:log-analyze

log-analyze runs EXPLAIN ANALYZE on all queries regardless if they’re logged or not. This setting can have a significant performance impact on your database so use with caution. The default value is off.

$ heroku pg:settings:auto-explain:log-analyze postgresql-large-1234 on -a example-app

auto-explain:log-buffers

log-buffers is equivalent to calling EXPLAIN BUFFERS and can only be used with pg:settings:auto-explain:log-analyze turned on.

The default value is off.

$ heroku pg:settings:auto-explain:log-buffers postgresql-large-1234 on -a example-app

auto-explain:log-format

log-format sets the format for the EXPLAIN command. The default value is text. The format options for log-format are:

  • text
  • xml
  • json
  • yaml.
$ heroku pg:settings:auto-explain:log-format postgresql-large-1234 json -a example-app

auto-explain:log-min-duration

log-min-duration configures a minimum log duration in milliseconds. Setting a log duration of -1 disables all logging, while setting a log duration of 0 logs all executed queries. The default value is -1.

$ heroku pg:settings:auto-explain:log-min-duration postgresql-large-1234 200 -a example-app

auto-explain:log-nested-statements

log-nested-statements adds nested statements to the execution plan’s log. The default value is off.

$ heroku pg:settings:auto-explain:log-nested-statements postgresql-large-1234 on -a example-app

auto-explain:log-triggers

log-triggers includes trigger execution statistics in the execution plan’s logs. The default value is off.

$ heroku pg:settings:auto-explain:log-triggers postgresql-large-1234 on -a example-app

auto-explain:log-verbose

log-verbose includes verbose details in the execution plan’s logs. This setting is equivalent to running EXPLAIN VERBOSE. The default value is off.

$ heroku pg:settings:auto-explain:log-verbose postgresql-large-1234 on -a example-app

Keep reading

  • Postgres Basics

Feedback

Log in to submit feedback.

Upgrading the Version of a Heroku Postgres Database Heroku Postgres

Information & Support

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

Language Reference

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

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices