Skip to content

Query Analysis


Query Analysis is an independent analysis entry point in the Database module, supporting cross-instance aggregated query display. When you manage multiple database instances, you can locate system-wide slow query bottlenecks from a global perspective without having to enter each instance detail page individually.

Supported Database Types

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


Positioning

Unlike the Explorer, which analyzes queries at a single-instance level, the core capabilities of Query Analysis include:

  • Cross-instance aggregation: The same business SQL executed on multiple instances is automatically aggregated into global cumulative data, eliminating the need to inspect each instance individually.
  • Similar query merging: The system automatically identifies and merges similar SQL queries with different parameter values (e.g., WHERE id = 1 and WHERE id = 2) into the same query template for statistics, preventing the same statement from being displayed separately due to parameter differences.
  • Global performance sorting: Supports sorting by multiple dimensions such as total duration, execution count, and average duration to quickly identify global performance bottlenecks.

Page Layout

The Query Analysis page consists of a top action bar, a left quick filter, a query list, and a detail side panel.

Top Action Bar

Element Description
Database Type Selector Dropdown to switch between MySQL / PostgreSQL / Oracle / SQL Server / MongoDB. After switching, the list reloads for that type.
SQL Template Search Supports searching SQL templates by keyword; input limit of 512 bytes.
Total Query Count Displays the number of query templates under the current filter criteria.
Export Exports the current list page as a CSV file, TXT, or to a dashboard.
Display Columns Supports customizing which columns are shown/hidden in the list.

Left Quick Filter

Filter Dimension Description
Instance Name Multi-select, displays all instances under the current database type.
Database Address Multi-select, filters by database connection address.
Total Duration Range-based filter.
Execution Count Range-based filter.
Time Range Linkage

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


Query List

The list displays all query templates aggregated under the current time range and database type. Each record represents a class of SQL (parameters replaced with ?) and summarizes the execution data of that class across all selected instances.

List Fields

Field Description
SQL Template The SQL text with parameters replaced by ?. Displays up to 2 lines. Click to expand the detail side panel.
Execution Count Cumulative execution count of this class of query across all instances within the time range.
Average Duration Average single execution time of this class of query.
Total Duration Cumulative execution time of this class of query across all instances within the time range.
Performance Cost Ratio The percentage of this class of query's cumulative total duration relative to the cumulative total duration of all queries. Visualized as a progress bar. A higher ratio indicates greater impact on overall system performance.
Average Rows Scanned Average number of rows scanned/returned across all instances for this class of query, used to evaluate the data scan range.
Trend Mini line chart (sparkline) of execution count within the current time range, linked to the list page time range.
SQL Template vs. Original SQL

The SQL template displayed in the list replaces specific parameter values with ? to help you focus on the statement structure itself. In the detail side panel, you can view the most recent original SQL sample under this template and copy the full text with one click.


Query Detail Side Panel

Clicking any row in the list slides out the query detail side panel on the right, showing the global performance data for that class of query. The side panel includes the following tabs:

Full SQL

The complete SQL template for this class of query (parameters replaced with ?) is fixed at the top of the side panel, supporting one-click copy.

Performance Trend

Linked to the list page time range, this displays three core metrics for this class of query in time series charts:

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

Each metric is displayed in an independent time series chart, supporting time interval filtering or chart export.

Instances

Displays the execution distribution of this class of query across instances, helping to identify which instance is the bottleneck.

Field Description
Database Address Connection address of the instance.
Instance Name Database instance identifier.
Execution Count Execution count of this class of query on this instance, visualized with a progress bar.
Average Duration Average execution time of this class of query on this instance.
Total Duration Cumulative execution time of this class of query on this instance, visualized with a progress bar.
Average Rows Sent Average number of rows returned by this class of query on this instance.
Error Count Number of failed executions of this class of query on this instance.
  • The instance name is clickable, opening a new page that shows the single-instance query detail page (reusing the existing Explorer details).
  • Supports filtering by instance name or database address in the search box.

Users

Displays the execution distribution of this class of query across different database accounts.

Field Description
User Database account name.
Sample Count Number of times this user executed this class of query.
Average Duration Average time of this user executing this class of query.
  • Supports filtering by username in the search box.

Query Samples

Displays actual sampling records for this class of query. Fields vary by database type.

MySQL Example Fields:

Field Description
Time Timestamp of the sample.
Database Target database (Schema).
Execution Duration Actual execution time of this sample.
User Database account that executed this sample.
Wait Group Wait event group of this sample.
Field Differences Across Database Types

The displayed fields for query samples depend on the database type. For example, SQL Server shows fields such as "Session ID, Wait Type, CPU Time", while Oracle and PostgreSQL display their native performance fields. Refer to the actual page for specific fields.


Metric Calculation Explanation

Aggregated metrics in Query Analysis are calculated as follows:

Metric Calculation Description
Execution Count Sum of execution counts of this class of query across all instances.
Average Duration Cumulative total duration across all instances ÷ Cumulative execution count across all instances.
Total Duration Sum of the duration of this class of query across all instances.
Performance Cost Ratio Cumulative total duration of this class of query ÷ Cumulative total duration of all queries × 100%.
Average Rows Scanned Average of the average rows scanned per instance for this class of query across all instances.
Data Timeliness Notes

Query Analysis data is aggregated in real-time based on the time range selected by the user. If an instance does not report data within the selected time range, it will not appear in the aggregation results.