Can I log all queries that run on my Heroku Postgres database?

Issue

You want to send a log statement to your log stream for each query that runs on your database.

Resolution

Heroku Postgres now allows the log level to be configured via Postgres settings https://devcenter.heroku.com/articles/heroku-postgres-settings#log-statement

Please note the all setting is generally only intended for debugging purposes, as it can quickly cause significant performance issues for production databases.

If you're trying to identify specific long-running queries, we already log all queries that run longer than 2 seconds. You can also view your most expensive queries at postgres.heroku.com, which is usually a better place to start for optimizing performance.

Finally, you can connect to your database by running heroku pg:psql on the command line and run queries directly there. You can put EXPLAIN ANALYZE in front of the query to get detailed performance information, and paste the output into explain.depesz.com to understand a specific query.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support
Terms of Service Privacy Cookies © 2018 Salesforce.com