You can use ️SQL Explorer to diagnose SQL health and troubleshoot performance issues. This topic describes how to use ️SQL Explorer within SQL Explorer and Audit.
Prerequisites
-
The database instance has been added to DAS and its connection status is Normal Connection.
-
SQL Explorer and Audit is enabled for the instance. For more information, see Enable SQL Explorer and Audit.
How it works
When enabled, SQL Explorer records all DQL, DML, and DDL operations. SQL Explorer captures this information directly from the database kernel with a negligible impact on CPU usage.
Supported databases and regions
For information about the databases and regions supported by each version of DAS Enterprise Edition, see Product editions.
Usage notes
-
Analytical and statistical data in SQL Explorer, excluding SQL details, is retained for 30 days.
-
The retention period for SQL detail data in SQL Explorer is the same as the retention period configured for DAS Enterprise Edition.
-
Disabling SQL Explorer and Audit does not affect your services, but the action clears all stored data for this feature. Before disabling the feature, export and save the required data to a local machine. For more information, see Disable SQL Explorer and Audit.
-
When an SQL statement is executed on an ApsaraDB RDS for MySQL instance attached to PolarDB-X 1.0, multiple SQL logs are generated on the ApsaraDB RDS for MySQL instance due to sharding.
-
Data migration can cause transient disconnections, potentially leading to data loss in SQL Explorer during the migration.
-
When a database instance is under a very high load, a small number of records may be lost. As a result, statistics for incremental data from SQL Explorer may be inaccurate.
-
A parameter determines the maximum length of a recorded SQL statement. SQL Explorer does not record any part of a statement that exceeds this limit. Because a prefix is added during data collection, the actual recorded length is slightly less than the configured parameter value.
Note-
For versions 5.6 and 5.7 of ApsaraDB RDS for MySQL and PolarDB for MySQL, the recorded length is controlled by the loose_rds_audit_max_sql_size parameter.
-
For version 8.0 of ApsaraDB RDS for MySQL and PolarDB for MySQL, the recorded length is controlled by the loose_rds_audit_log_event_buffer_size parameter.
-
-
For ApsaraDB RDS for PostgreSQL instances, if a PgBouncer connection pool is enabled, SQL statements executed through PgBouncer are not recorded by SQL Explorer.
Procedure
Log on to the DAS console.
In the navigation pane on the left, click .
Find the target instance and click the instance ID to open the instance details page.
-
In the left-side navigation pane, click , and then click the SQL Explorer tab.
-
Select a feature based on your needs:
NoteWhen you select a time range, the end time must be later than the start time, and the interval cannot exceed one day. After you enable DAS Enterprise Edition for the instance, you can query data from any day within the SQL Explorer storage duration.
-
Display by Time Range: Select a time range to view the SQL Explorer results. You can view the Execution Duration Distribution, Execution Duration, and Executions of all SQL statements within the selected time range. You can also view the details of all SQL statements in the Full Request Statistics section and export the results.
NoteYou can export up to 1,000 SQL logs. To obtain more SQL logs or cover a longer time range, use the Audit feature.
-
Display by Comparison: Select the time points for which you want to compare SQL Explorer results. You can view a comparison of the Execution Duration Distribution, Execution Duration, and Executions for all SQL statements. You can also view detailed comparison results in the Requests by Comparison section.
-
Source Statistics: Select a time range to view statistics about SQL sources. You can view the source information for all SQL statements within the selected time range.
-
SQL Review: Performs a workload analysis on a database instance for a selected time range and a baseline time range. It also performs an in-depth analysis of the SQL statements running on the instance and provides index optimization suggestions, SQL rewrite suggestions, TOP SQL, new SQL, failed SQL, SQL feature analysis, SQL with execution changes, SQL with performance degradation, and TOP traffic tables. For more information, see SQL Review.
-
Related SQL Identification: Select the metrics that you want to view and click Analysis. After 1 to 5 minutes, the system identifies and displays SQL statements with trends that most closely match the selected metrics within the specified time range.
Important-
For SQL Explorer and Audit that uses hot and cold storage, the system moves data older than seven days to cold storage. When you analyze SQL detail data older than seven days, the system creates a task to recalculate and analyze the data. You can view task progress and history on the Task list page.
-
Queries on SQL Explorer and Audit data older than seven days are charged on a pay-as-you-go basis. For more information, see billing details.
-
Results
-
Execution Duration Distribution: Shows the execution duration distribution of all SQL statements within the selected time range. The execution duration is divided into seven intervals, calculated once per minute:
-
[0,1]msindicates the percentage of SQL executions with a duration from 0 ms to 1 ms (inclusive). -
(1,2]msindicates the percentage of SQL executions with a duration greater than 1 ms and up to 2 ms. -
(2,3]msindicates the percentage of SQL executions with a duration greater than 2 ms and up to 3 ms. -
(3,10]msindicates the percentage of SQL executions with a duration greater than 3 ms and up to 10 ms. -
(10,100]msindicates the percentage of SQL executions with a duration greater than 10 ms and up to 100 ms. -
(0.1,1]sindicates the percentage of SQL executions with a duration greater than 0.1s and up to 1s. -
>1sindicates the percentage of SQL executions with a duration greater than 1s.
NoteThe closer the Execution Duration Distribution of an instance is to blue, the healthier its SQL performance. The closer it is to orange and red, the poorer its SQL performance.
-
-
Execution Duration (SQL RT): Displays the execution duration of SQL statements within the selected time range.
-
Full Request Statistics: Displays the SQL text, duration percentage, average execution duration, and execution trend for each type of SQL statement within the selected time range.
NoteDuration percentage is the total execution duration of a specific SQL type as a percentage of the total execution duration of all SQL types. SQL types with a higher duration percentage consume more resources on the MySQL instance.
-
SQL ID: Click an SQL ID to view the performance trend and SQL samples for that statement.
-
SQL Sample: Use an SQL Sample to identify which client application initiated the SQL statement.
NoteSQL samples use UTF-8 encoding.
FAQ
Related APIs
|
API |
Description |
|
Asynchronously queries up to 20 samples of failed SQL queries from the SQL Explorer results of a database instance within a specified time range. |
|
|
Asynchronously retrieves the number of failed executions for a specified SQL statement from the SQL Explorer results of a database instance. |
|
|
Asynchronously queries the SQL IDs of statements that generated a specified MySQL error code from the SQL Explorer results of a database instance. |
|
|
Asynchronously queries the MySQL error codes and the number of SQL queries corresponding to each error code from the SQL Explorer results of a database instance. |
|
|
Gathers statistics on full request data from the SQL Explorer results of a database instance, categorized by access source. |
|
|
Asynchronously gathers statistics on full request data from the SQL Explorer results of a database instance, categorized by SQL ID. |
|
|
Queries up to 20 SQL samples by SQL ID from the SQL Explorer results of a database instance. |
|
|
Queries the details of data in hot storage from the last seven days for SQL Explorer and Audit of a database instance. |