Skip to content

Query Analysis


Query Analysis is an independent analysis entry point within the Database module, supporting cross-instance aggregated query display. When you manage multiple database instances, you can identify system-level 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, and SQL Server. After switching the database type, the list reloads the query data of the corresponding instances for that type.


Functional Overview

Unlike the per-instance query analysis in the Explorer, the core capabilities of Query Analysis include:

  • Cross-instance aggregation: When the same business SQL executes on multiple instances, it 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 ranking: Supports sorting by multiple dimensions such as total duration, execution count, and average duration, enabling rapid discovery of global performance bottlenecks.

Page Layout

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

Top Action Bar

Element Description
Database Type Selector Dropdown to switch between MySQL / PostgreSQL / Oracle / SQL Server. The list reloads for the selected type.
SQL Template Search Supports keyword search for SQL templates. Input limit: 512 bytes.
Total Queries Displays the number of query templates under the current filter conditions.
Export Export the current list page as a CSV file, TXT file, or to a dashboard.
Display Columns Customize which columns to show/hide in the list.

Left-Side Quick Filters

Filter Dimension Description
Instance Name Multi-select. Displays all instances under the current database type.
Database Address Multi-select. Filter 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. Both the list data and the 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 row represents a class of SQL (parameters replaced with ?) and summarizes the execution data of that class across all selected instances.

List Columns

Column Description
SQL Template The SQL text with parameters replaced by ?. Displays up to 2 lines in the list. Click to expand the detail side panel on the right.
Execution Count Total number of executions of this query class across all instances within the time range.
Average Duration Average single execution time for this query class.
Total Duration Cumulative execution time of this query class across all instances within the time range.
Performance Overhead Percentage Percentage of the cumulative total duration of this query class relative to the cumulative total duration of all queries, visualized as a progress bar. The higher the percentage, the greater the impact of this query class on overall system performance.
Average Rows Scanned Average number of rows scanned/returned for this query class across all instances, used to evaluate the data scan range of the query.
Trend A mini sparkline chart of execution counts within the current time range, linked to the time range of the list page.
SQL Template vs. Original SQL

The SQL template displayed in the list has replaced specific parameter values with ?, allowing you to 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

Click any row in the list, and the query detail side panel slides out from the right, displaying the global performance data of that query class. The side panel includes the following tabs:

Full SQL

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

Performance Trend

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

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

Each metric has its own time series chart, supporting time interval filtering or chart export.

Instances

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

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

Users

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

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

Query Samples

Displays actual sampling records of this query class. The fields vary by database type.

MySQL Example Fields:

Column Description
Time Timestamp of the sample.
Database Target database (Schema).
Duration Actual execution time of this sample.
User Database account that executed this sample.
Wait Group Wait event group of this sample.
Differences in Sample Fields Across Databases

The displayed fields of query samples depend on the database type. For example, SQL Server shows fields such as Session ID, Wait Type, and CPU Time, while Oracle and PostgreSQL also show their respective native performance fields. The actual fields displayed on the page may vary.


Metrics Calculation Explanation

The aggregated metrics in Query Analysis are calculated as follows:

Metric Calculation Explanation
Execution Count Sum of execution counts of this query class across all instances.
Average Duration Cumulative total duration across all instances ÷ Cumulative total execution count across all instances.
Total Duration Sum of durations of this query class across all instances.
Performance Overhead Percentage Cumulative total duration of this query class ÷ Cumulative total duration of all queries × 100%.
Average Rows Scanned Average of the average rows scanned of this query class across all instances.
Data Timeliness

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


Feedback

Is this page helpful?