Skip to content

Query Analysis


Query Analysis is a standalone analysis entry point in the Database module. It supports cross-instance query aggregation. When you manage multiple database instances, you can identify system-level slow query bottlenecks from a global perspective without opening each instance's details page.

Supported Database Types

Query Analysis currently supports MySQL, PostgreSQL, Oracle, SQL Server, and MongoDB. After you switch the database type, the list reloads the query data of the corresponding instances for that type.


Capabilities

Unlike the Explorer, which analyzes queries on a single-instance basis, Query Analysis provides the following core capabilities:

  • Cross-instance aggregation: When the same business SQL is executed on multiple instances, it is automatically aggregated into global cumulative data, so you do not need to troubleshoot instance by instance.
  • Similar query consolidation: The system automatically identifies similar SQL statements with different parameter values (for example, WHERE id = 1 and WHERE id = 2) and consolidates them into a single query template for statistics, preventing the same statement from being scattered due to parameter differences.
  • Global performance ranking: Supports sorting by total time, execution count, average time, and other dimensions to quickly identify global performance bottlenecks.

Page Layout

The Query Analysis page consists of a top action bar, left-side quick filters, a query list, and a details side panel.

Top Action Bar

Element Description
Database type selector Dropdown to switch among MySQL / PostgreSQL / Oracle / SQL Server / MongoDB. After switching, the list reloads for that type
SQL template search Search SQL templates by keyword. The input is limited to 512 bytes
Total queries Shows the number of query templates under the current filter conditions
Export Exports the current list as a CSV file, TXT, or to a dashboard
Columns Customize which list columns are shown or hidden

Left-Side Quick Filters

Filter dimension Description
Instance name Multi-select. Shows all instances of the current database type
Database address Multi-select. Filter by database connection address
Total time Filter by range segments
Execution count Filter by range segments
Time Range Linkage

The time range of Query Analysis is linked to the global Time Widget. Both the list data and the trend charts in the details side panel are aggregated in real time based on the selected time window.


Query List

The list shows all aggregated query templates for the current time range and database type. Each record represents one class of SQL (with parameters replaced by ?) and aggregates the execution data of that class across all selected instances.

List Fields

Field Description
SQL template The SQL text with parameters replaced by ?, displayed in up to 2 lines. Click to expand the details side panel on the right
Execution count The cumulative number of executions of this query class across all instances within the time range
Average time The average execution time per execution for this query class
Total time The cumulative execution time of this query class across all instances within the time range
Performance overhead ratio The percentage of the cumulative total time of this query class relative to the cumulative total time of all queries, visualized with a progress bar. The higher the ratio, the greater the impact of this query class on overall system performance
Average scanned rows The average number of scanned/returned rows for this query class across all instances, used to evaluate the data scan scope of the query
Trend A sparkline (mini line chart) of the execution count within the current time range, linked to the time range of the list page
SQL Template vs. Raw SQL

The SQL templates in the list have concrete parameter values replaced with ? so that you can focus on the statement structure itself. In the details side panel, you can view the most recent raw SQL sample for this template and copy the full text with one click.


Query Details Side Panel

Click any row in the list to slide out the Query Details side panel on the right, which shows the global performance data of this query class. The side panel contains the following tabs:

Complete SQL

The top of the side panel displays the complete SQL template of this query class (with parameters replaced by ?), with one-click copy supported.

Performance Trend

Linked to the time range of the list page, the performance trend displays three core metrics of this query class as time series charts:

Chart Description
Execution count Executions per minute, reflecting the concurrency pressure trend of this query class
Average time Milliseconds (ms), reflecting the per-execution efficiency trend of this query class
Total time Milliseconds (ms), reflecting the time consumption trend of this query class in the overall system

Each metric is displayed as an independent time series chart. You can select a time interval to filter the data or export the chart.

Instances

Shows the execution distribution of this query class across instances, helping you determine which instance the bottleneck is concentrated on.

Field Description
Database address The connection address of the instance
Instance name The database instance identifier
Execution count The number of executions of this query class on the instance, visualized with a progress bar
Average time The average execution time of this query class on the instance
Total time The cumulative execution time of this query class on the instance, visualized with a progress bar
Average rows sent The average number of rows returned by this query class on the instance
Error count The number of failed executions of this query class on the instance
  • The instance name is clickable and opens the single-instance query details page for that instance in a new tab (reusing the existing Explorer details).
  • You can filter by instance name or database address in the search box.

Users

Shows the execution distribution of this query class across database accounts.

Field Description
User The database account name
Sample count The number of times this user executed this query class
Average time The average time for this user to execute this query class
  • You can filter by user name in the search box.

Query Samples

Shows the actual sampled records of this query class. The fields vary by database type.

Example fields for MySQL:

Field Description
Time The timestamp when the sample was captured
Database The target database (schema)
Execution time The actual execution time of this sample
User The database account that executed this sample
Wait group The wait event group of this sample
Sample Field Differences Across Databases

The sample fields are related to the database type. For example, SQL Server shows fields such as session ID, wait type, and CPU time. Oracle and PostgreSQL also show their respective native performance fields. The specific fields are subject to what is actually displayed on the page.

Execution Plan

Click a SQL template in the query list to open the details side panel and go to Execution Plan. The execution plan describes the execution method chosen by the database optimizer for the current query. You can use it to determine whether the query has problems such as full table scans, improper index usage, or high JOIN costs.

Supported Database Types

The Execution Plan currently supports MySQL, PostgreSQL, Oracle, and SQL Server. MongoDB is not supported yet. The execution plan is displayed only when execution plan collection is enabled in the current environment and the corresponding plan data has been collected.

Selecting an Execution Plan

The same query may use different execution plans on different database instances, and multiple plans may exist on the same instance. You can switch between them using the selector at the top of the page. The options consist of an instance name and a plan identifier, for example prod-sql-01 · 0x72AE91F3.

With SQL Server, for example, the plan identifier is displayed as Plan Hash. When the Plan Hash of the same query changes, it usually indicates that the database has adopted a different execution plan.

After you select a plan, the page shows the database instance, database name, and plan identifier associated with the plan.

Recommendations

We recommend first using Performance Trend and Instances to locate time anomalies, and then going to Execution Plan to review node dependencies and high-cost operations. The topology graph is suitable for understanding the overall execution path, the node list is suitable for comparing node data, and XML / JSON is suitable for viewing the complete raw information returned by the database.

Topology Graph

The topology graph shows the database execution steps according to the node hierarchy in the execution plan. The connections between nodes represent the dependencies between nodes, not the actual execution timeline of the query.

Each node shows the following information based on the data returned by the database:

  • The execution operation name;
  • The logical operation (shown only when the original plan contains this field and it differs from the execution operation);
  • The table or index accessed;
  • Rows: the number of rows the database optimizer estimates the node will output;
  • Cost: the relative cost of the current node and its child nodes.

You can zoom in, zoom out, drag, or fit the entire topology graph to the view. Hover over a node to view additional information such as the execution operation, logical operation, accessed object, estimated rows read, filter conditions, JOIN conditions, or native database warnings. The page only shows fields that actually exist in the original plan.

Understanding Rows and Cost

Estimated Rows is the number of rows the database optimizer estimates the node will output, not the actual number of rows processed. Node Cost is used to compare the relative cost of nodes within the same execution plan. It does not represent actual execution time and is not suitable for direct comparison across different databases.

Node List

The node list shows the node hierarchy of the execution plan with indentation, making it easy to quickly compare the accessed objects, estimated rows, and node costs across nodes. The list order expresses the hierarchical relationships between nodes, not the actual execution time order.

Field Description
Execution step The execution operation name and node level returned by the database
Accessed object / index The table, view, or index accessed by the current node
Estimated Rows The number of rows the database optimizer estimates the node will output. When the original plan also includes the rows read, the output and read values are shown separately
Node Cost The relative cost of the current node and its child nodes

XML / JSON

The raw view shows the complete execution plan obtained by the collector. It supports formatting, searching, copying, and downloading.

Database Raw format Download format
SQL Server XML Downloaded as .sqlplan when it conforms to the ShowPlan XML format; other XML is downloaded as .xml
MySQL JSON .json
PostgreSQL JSON .json
Oracle JSON .json
Notes on Execution Plan Data

The execution plan comes from data already obtained by the collector. The system does not re-execute user SQL to view the plan, nor does it proactively run EXPLAIN or EXPLAIN ANALYZE. The execution plan may not have been generated within the time range currently selected on the page, nor does it necessarily correspond to a specific execution. Whether actual row counts and actual execution time are included depends on the original plan returned by the database.


Notes on Metric Calculation

The aggregated metrics in Query Analysis are calculated as follows:

Metric Calculation
Execution count The sum of the execution counts of this query class across all instances
Average time Cumulative total time across all instances ÷ cumulative execution count across all instances
Total time The sum of the execution times of this query class across all instances
Performance overhead ratio Cumulative total time of this query class ÷ cumulative total time of all queries × 100%
Average scanned rows The average of the average scanned row counts of this query class across all instances
Notes on Data Timeliness

The data in Query Analysis is aggregated in real time based on the time range selected by the user. If an instance reports no data within the selected time range, that instance will not appear in the aggregation results.