All Products
Search
Document Center

ApsaraDB for ClickHouse:Monitor slow SQL queries and manage running SQL queries

Last Updated:Jan 17, 2024

If your ApsaraDB for ClickHouse cluster encounters performance issues or when you perform periodic maintenance, you can view slow SQL queries to troubleshoot the issues. This topic describes how to monitor slow SQL queries and manage running SQL queries in the ApsaraDB for ClickHouse console.

Background information

The process of writing raw query logs to tables is complex. You need to perform operations such as installing clients, writing SQL statements, and sorting results. The trend of slow SQL queries cannot be displayed in an intuitive manner. This results in high costs, poor usability, and low efficiency. ApsaraDB for ClickHouse displays query logs by using graphical interfaces. ApsaraDB for ClickHouse allows you to perform visual retrieval by key dimensions and analyze the statistics of slow SQL queries. You can summarize and analyze log data with only a few clicks. This helps you identify and handle issues.

Monitor slow SQL queries

You can collect statistics to display the trend of slow SQL queries and view the details of slow SQL queries over the specified time range in the console to monitor slow SQL queries.

  1. Log on to the ApsaraDB for ClickHouse console.

  2. In the top navigation bar, select the region where the cluster that you want to manage is deployed.

  3. On the Clusters page, click the Default Instances tab, find the cluster that you want to manage, and then click the ID of the cluster.

  4. In the left-side navigation pane, click Query Management.

  5. On the Query Management page, click the Slow Queries tab.

  6. Customize a runtime for slow SQL queries. By default, queries whose runtime exceeds 3,000 ms are considered slow SQL queries.

    Note

    The minimum runtime for slow SQL queries is 500 ms.

  7. You can select Slow SQL Trend or Slow SQL Details from the drop-down list and specify time-related filter conditions to view the trend or details of slow SQL queries.

    Click image.png to export the data of filtered slow SQL queries.

Manage running SQL queries

The Running Queries tab of ApsaraDB for ClickHouse displays running SQL queries in real time. You can view the details of running SQL queries and terminate selected SQL queries to temporarily release resources.

  1. Log on to the ApsaraDB for ClickHouse console with your Alibaba Cloud account.

  2. In the top navigation bar, select the region where the cluster that you want to manage is deployed.

  3. On the Clusters page, click the Default Instances tab, find the cluster that you want to manage, and then click the ID of the cluster.

  4. In the left-side navigation pane, click Query Management.

  5. On the Query Management page, click the Running Queries tab.

  6. To filter query results, select User, SQL Keywords, or Initial Query ID from the drop-down list.

    Note

    If you do not configure a filter condition, all running SQL queries are displayed by default.

  7. If the cluster fails or the resource usage reaches the threshold, select the slow SQL queries that cause the issue, and then click Terminate Selected Queries to terminate the selected query requests. You can also click Terminate All Queries to terminate all query requests.