You want to send a log statement to your log stream for each query that runs on your database.
Heroku Postgres now allows the log level to be configured via Postgres settings. More information is available in Dev Center.
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.