Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
All solutions
    • All solutions for Managed PostgreSQL
    • Recovering a Managed Services for PostgreSQL cluster after its disks become Read Only
    • You are unable to delete your Managed Service for PostgreSQL cluster in the Dead status if deletion protection was enabled for it
    • Managed Service for PostgreSQL cluster switches to the Unknown state immediately after creation
    • Resolving issues with updating configurations of clusters with local-ssd disks
    • Resolving the consequences 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"
    • Resolving the error Unrecognized configuration parameter "stats_temp_directory"
    • Resolving the "max_connections conn_limit is too high" error
    • Resolving the "422 UNPROCESSABLE ENTITY The specified extension <'ext_name'> is not present in shared_preload_libraries" error
    • Understanding the Conn limit parameter
    • How to set up SQL query filtering
    • How to enable SQL query logging

In this article:

  • Scenario description
  • Solution
  1. Managed PostgreSQL
  2. How to enable SQL query logging

How to enable SQL query logging

Written by
Yandex Cloud
Updated at August 14, 2024
  • Scenario description
  • Solution

Scenario descriptionScenario description

You need to enable SQL query logging.

SolutionSolution

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

Additionally, check the Auto explain sample rate=1 and Auto explain log analyze settings as shown in the guide.

Next, enable the Log min duration statement parameter. We do not recommend setting the value to 1 ms as this would keep the cluster busy with log recording only.

You can enable this parameter via the UI, on the cluster settings page, using DBMS settings or this YC CLI command:

yc managed-postgresql cluster update-config <имя кластера> --set log_min_duration_statement=100

After that, you can view the log records, for example, 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 Yandex Monitoring
Yandex project
© 2025 Yandex.Cloud LLC