Help Center> Relational Database Service> Best Practices> PostgreSQL> Viewing Slow Query Logs of PostgreSQL DB Instances

Viewing Slow Query Logs of PostgreSQL DB Instances

Scenarios

Slow query logs record statements that exceed the log_min_duration_statement value (1 second by default). You can view log details and statistics to identify statements that are slowly executed and optimize the statements. RDS supports the following statement types:
  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE
  • DROP
  • ALTER
  • DO
  • CALL
  • COPY

Parameter Description

Table 1 Parameters related to PostgreSQL slow queries

Parameter

Description

log_min_duration_statement

Specifies the minimum execution time. The statements whose execution time is greater than or equal to the value of this parameter are recorded.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click Service List. Under Database, click Relational Database Service to go to the RDS console.
  4. On the Instance Management page, click the target DB instance.
  5. In the navigation pane on the left, choose Logs. On the Slow Query Logs page, click Log Details.

    You can view the slow query log records of a specified statement type in a specified time period.