All Products
Search
Document Center

Slow query logs

Last Updated: Aug 25, 2021

In business scenarios, slow queries are performed on a Time Series Database (TSDB) instance. This causes heavy loads and compromises the performance of the TSDB instance. To troubleshoot issues that degrade the instance performance, you can use the Slow query log module in the TSDB console.

Procedure

  1. Log on to the TSDB console.

  2. On the Instances page, find the instance that you want to manage and click Manage in the Actions column.

  3. In the left-side navigation pane, choose Time Series Data Management > Slow query log.

  4. In the upper-left corner of the Slow query log page, specify a time range to search for the desired slow query logs and click Search. Then, you can view all slow queries that are performed on the TSDB instance within the specified time range.

Note

Queries that take longer than 1 second to run are slow queries. Queries that take less than 1 second to run are not recorded.

The following list describes the parameters of slow queries.

  • Execution time

    The time taken for a slow query to run on TSDB.

  • Log time

    The time when a slow query is logged.

    If a query is slow, TSDB logs the query. Query logging is not based on whether the query succeeds or fails. TSDB determines whether the query is slow based on the time taken to run the query.

  • Statement

    The query conditions that are received by the TSDB instance. The query conditions are deserialized. The actual statement that you execute can contain extra internal fields.

  • Source IP

    The IP address of the client from which a query is sent. The IP address varies based on network types. For example, the IP address can be a private IP address if the TSDB instance is deployed in a virtual private cloud (VPC).

Notice

You can use the Slow query log module in the TSDB console only when the following conditions are met:

  1. The version of the engine on which the TSDB instance runs is later than V2.6.7. For more information about how to view the engine version, see View the details of an instance.

  2. The account that you use to log on to the TSDB console has the AliyunHiTSDBReadOnlyAccess permission.

After you identify slow queries based on the slow query logs, you can take measures to optimize the slow queries. For example, you can reduce the amount of time series data to query or reduce the number of data points to query. This can make queries efficient. For more information, see Reduce the amount of time series data to query and Reduce the number of data points to query.