Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
All solutions
    • All solutions for Managed Service for PostgreSQL
    • Restoring a Managed Service for PostgreSQL cluster after running out of free storage space
    • You are unable to delete your Managed Service for PostgreSQL cluster in the `DEAD` status if it has deletion protection enabled
    • Managed Service for PostgreSQL cluster switches to `UNKNOWN` once created
    • Resolving issues with updating configurations of clusters with `local-ssd` disks
    • Resolving the issue of cluster storage overflow with WAL logs
    • Resolving the `psql error could not translate host name to address nodename nor servname provided, or not known` error
    • Resolving the `Unrecognized configuration parameter stats_temp_directory` error
    • Resolving the `max_connections conn_limit is too high` error
    • Resolving the `Must be superuser to create this extension` error
    • Fixing the `terminating connection due to administrator command` and `ERROR: odyssey: remote server read/write error` errors
    • Resolving the `422 UNPROCESSABLE ENTITY The specified extension <'ext_name'> is not present in shared_preload_libraries` error
    • How `Conn limit` works
    • How to set up SQL query filtering
    • How to enable SQL query logging

In this article:

  • Case description
  • Solution
  1. Managed Service for PostgreSQL
  2. How to enable SQL query logging

How to enable SQL query logging

Written by
Yandex Cloud
Updated at December 17, 2025
  • Case description
  • Solution

Case descriptionCase description

You need to enable SQL query logging.

SolutionSolution

To enable query logging, make sure pg_stat_statements is installed. This extension adds an option to track execution plans and collect the statistics of all SQL queries run in the cluster. You must have the mdb_monitor role to use it.

You also need to check the Auto explain sample rate=1 and Auto explain log analyze settings following this guide and enable Log min duration statement. We do not recommend setting the 1 ms value as this will keep the cluster busy with logging only.

You can enable this setting from the management console by selecting DBMS settings, or by using this YC CLI command:

yc managed-postgresql cluster update-config <cluster name> --set log_min_duration_statement=100

After that, you can view the log records, e.g., via the YC CLI:

yc managed-postgresql cluster list-logs --service-type postgresql --since '2h' --until '1s' --id=YOUR-CLUSTER-ID

Was the article helpful?

Previous
How to set up SQL query filtering
Next
All solutions for Monitoring
© 2025 Direct Cursus Technology L.L.C.