Updated on 2024-05-21 GMT+08:00

Viewing Slow Query Logs

Slow query logs record statements that exceed the value slowlog_query_duration_ms (1 second by default and its value cannot be modified). You can use these logs to identify and optimize the statements that are executing slowly.

HTAP instances support the following statement types:
  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE
  • ALTER
  • DROP

Viewing Log Details

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. On the Instances page, click the instance name to go to the Basic Information page.
  5. In the navigation pane on the left, choose HTAP Analysis.
  6. Click the name of an HTAP instance to go to the Basic Information page.
  7. In the navigation pane on the left, choose Logs.
  8. On the Slow Query Logs page, view the slow query log details.
  9. View slow query logs of different nodes in a given database and SQL statement types.

    Figure 1 Viewing slow query logs

    • Enter a database name, click the drop-down list, and select your desired node.
    • Click the drop-down list and select a SQL statement type (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP).
    • View logs generated in the last 15 minutes, last 30 minutes, last 1 hour, last 24 hours, last 7 days, or last 30 days. You can select Custom time range to set start time and end time to view the logs of the specified time range.

Showing Original Log

After Show Original Log is enabled, original logs are displayed.

Original logs will be automatically deleted 30 days later. If the instance is deleted, its logs are also deleted.

  1. On the Instances page, click the instance name to go to the Basic Information page.
  2. In the navigation pane on the left, choose HTAP Analysis.
  3. Click the name of an HTAP instance to go to the Basic Information page.
  4. In the navigation pane on the left, choose Logs.
  5. On the Slow Query Logs page, click next to Show Original Log.

    Figure 2 Enabling Show Original Log (1)

  6. In the displayed dialog box, click Yes.

    Figure 3 Enabling Show Original Log (2)

Reporting Slow Log to LTS

  1. On the Instances page, click the instance name to go to the Basic Information page.
  2. In the navigation pane on the left, choose HTAP Analysis.
  3. Click the name of an HTAP instance to go to the Basic Information page.
  4. In the navigation pane on the left, choose Logs.
  5. On the Slow Query Logs page, click next to Report Slow Log to LTS.

    Figure 4 Reporting slow logs to LTS (1)

  6. Select an LTS log group and log stream and click OK.

    Figure 5 Reporting slow logs to LTS (2)

    • Audit logs record all requests sent to the HTAP instance and are stored in LTS.
    • This function does not take effect immediately. There is a delay of about 10 minutes.
    • You will be billed for this function. For pricing details, see Billing Description.