Updated on 2024-12-13 GMT+08:00

Doris Slow Query Detection

Scenario

As a ROLAP database, Doris relies on a powerful relational database engine at its foundation. High concurrency and aggregation queries are commonly used. MRS Doris lacks slow query detection capabilities, making it difficult to monitor query execution for troubleshooting. To improve Doris's O&M capabilities, we developed the slow query detection function.

Doris slow query information can be displayed and managed on Manager only after this function enabled. By default, this function is disabled to reduce the impact on environment resources. You can enable this function with custom parameter query_history_enable.

This function is available only for MRS 3.5.0 and later versions.

Prerequisites

  • A cluster containing the Doris service has been created, and all services in the cluster are running properly.
  • The nodes to be connected to the Doris database can communicate with the MRS cluster.
  • The MySQL client has been installed. For details, see Using the MySQL Client to Connect to Doris.

Enabling Slow Query Detection

  1. Log in to FusionInsight Manager and choose Cluster > Services > Doris > Configurations > All Configurations > FE(Role) > Customization.
  2. Add the query_history_enable parameter to the custom parameter fe.conf.customized.configs and set the parameter value to true.
  3. Click Save, and then click OK to save the configurations.
  4. Click Instances, select the affected FE instances, choose More > Restart Instance. Enter the password of the user and click OK to apply the configuration.
  5. After connecting the MySQL client to Doris, run the following command to view the slow queries executed by the Doris:

    select * from __internal_schema.query_history;

  6. On FusionInsight Manager, choose Cluster > Services > Doris > Queries to view Ongoing Slow Queries and Completed Slow Queries. You can also view the top 10 users who execute slow queries, IP addresses of the clients that submit slow SQL statements, and slow query statements.

    • Top 10 Users: top 10 Doris users who perform slow queries
    • Top 10 IP Addresses: IP addresses of top 10 Doris clients that execute slow queries
    • Top 10 SQL Statements: top 10 most executed slow query SQL statements on the Doris client

Ongoing Slow Queries

You can query information about slow SQL statements that are being executed but do not return any result.

  • Access path

    Log in to FusionInsight Manager, choose Cluster > Services > Doris > Queries, and click the Ongoing Slow Queries tab. For details about the parameters, see Table 2.

  • Filter conditions

    Select the query condition as required and filter the query results.

    Table 1 Filter conditions

    Conditions

    Parameter Description

    Slow query duration exceeding

    Filters the slow SQL queries based on the duration.

    The value can be 3 (s), 9 (s), 15 (s), or 25 (s).

    By Query ID

    Filters the slow queries based on the query ID.

    Fuzzy search based on the query ID is supported. For example, if the query ID is 111-222-333-444-555, you can enter part of it such as 111-222 or -222-333 to query the needed information.

    By User

    Filters the slow queries based on Doris users who execute the SQL statements.

    Fuzzy search based on part of a username is supported.

    By Client IP Address

    Filters the slow queries based on the IP address of the client that submits slow query SQL statements.

    Fuzzy search based on part of the client IP address is supported. For example, if the client IP address is 192.168.0.1, you can enter part of it such as 192.168 or 192.168.0 to query the information you need.

Completed Slow Queries

You can query information about slow query SQL statements that have been executed and returned results.

Log in to FusionInsight Manager and choose Cluster > Services > Doris. On the displayed page, click the Query Management tab and then the Completed Queries tab.

For details about slow query parameters and filter conditions, see Table 2 and Table 1, respectively.

Slow Query Detection Parameters

Table 2 Slow query parameters

Parameter

Description

Query ID

Unique ID generated internally.

Query

Slow query SQL statement.

Start Time

Time when the query starts.

End Time

Time when the query is complete.

Database

Name of the database where the table in the query is.

Instance Name

FE instance node that executes the query. It is displayed for Ongoing Slow Queries only.

Memory Used

Memory space consumed by the query, in bytes. This field is displayed for Completed Queries only.

Duration

Total execution time of the query, in seconds.

User

Doris user who executes the query.

Client IP Address

IP address of the client that submits the query.

Status

Execution status of the query. Possible values are as follows:

  • Running: queries being executed
  • Cancelled: slow queries stopped by clicking Terminate in the Operation column in the Ongoing Slow Queries tab
  • Completed: slow queries that have been properly executed

Operation

Column available for Ongoing Slow Queries only. You can click Terminate to stop a query.