The SQL Explorer feature of PolarDB for MySQL has been upgraded to SQL Explorer and Audit. This service is provided by Database Autonomy Service (DAS). The Search (Audit) feature collects the details of all SQL statements. This lets you query and export SQL statements and their related information, such as the database, user, or client IP address that executed the SQL statement. The SQL Explorer feature helps you diagnose the health of SQL statements, troubleshoot performance issues, and analyze service traffic. This improves the efficiency of fault diagnosis, database optimization, and threat detection.
Feature introduction
Database Autonomy Service (DAS) integrates features such as Search, SQL Explorer, Security Audit, and Traffic Playback and Stress Testing based on full request data collection and security auditing. DAS helps you retrieve the details of SQL statements, troubleshoot performance issues, identify the sources of significant threats, and determine whether you need to scale out your cluster. This helps you effectively handle peak service traffic.
Search: You can query and export SQL statements and their corresponding information, such as the database, status, and running time. For more information, see Audit.
The SQL Explorer feature lets you diagnose the health of SQL statements, troubleshoot performance issues, and analyze service traffic. For more information, see SQL Explorer.
SQL Review: Provides global SQL payload analysis to help you quickly identify suspicious SQL statements in database instances, analyze them, and receive optimization suggestions. For more information, see SQL Review.
Traffic Replay and Stress Testing: Provides traffic replay and stress testing features to help you verify whether your instance type needs to be scaled out to effectively handle peak service traffic. For more information, see Traffic Replay and Stress Testing.
Security Audit: Automatically detects threats such as significant SQL queries, SQL injection, and new access sources. For more information, see Security Audit.
Transaction Analysis: You can use this feature to view the transaction types, number of transactions, and transaction details for a specific thread within a specified time period. This helps you understand, analyze, and optimize database performance at the transaction level. For more information, see Transaction Analysis.
Quick Transaction Analysis: This feature lets you identify the start and end statements of the transaction that contains the SQL statement to be analyzed. This helps you determine whether the transaction was committed or rolled back. For more information, see Quick Transaction Analysis.
Supported regions
You can use the SQL Explorer and Audit feature only after you enable DAS Enterprise Edition. The supported regions vary based on the edition. For more information, see Databases and regions supported by different editions.
Impact
The SQL Explorer feature records the information about all executed DQL, DML, and DDL statements. DAS obtains the information from database kernels, which consumes only a small amount of CPU resources.
Precautions
If you are a RAM user and want to use the Search feature, you must grant the AliyunPolardbReadOnlyWithSQLLogArchiveAccess permission to the RAM user. For more information about how to grant permissions to RAM users, see Create and manage RAM users.
You can also use custom policies to grant a RAM user the permissions to use the Search feature, including the log export feature. For more information, see Use custom policies to grant a RAM user the permissions to use the Search feature (including log export) of SQL Explorer and Audit.
Billing
Enterprise Edition V0
The SQL Explorer feature can be billed based on the pay-as-you-go billing method and does not support the subscription billing method. The related fees are categorized under PolarDB.
Prices
Regions in the Chinese mainland: USD 0.0013 per GB-hour
China (Hong Kong) and regions outside China: USD 0.0019 per GB-hour
Enterprise Edition V0 or later
(Optional) Billing rules for SQL Explorer For more information, see DAS billing.
Enable SQL Explorer and Audit
Log on to the PolarDB console. In the navigation pane on the left, click Cluster List. Select the Region where the cluster is located, and click the ID of the target cluster to go to the cluster details page.
In the navigation pane on the left, choose .
Click Enable SQL Explorer.
NoteIf DAS Enterprise Edition is not enabled for your Alibaba Cloud account, follow the on-screen instructions to enable it.
On the page that appears, click a tab to view related information.
Search (Audit): Query and export SQL statements and their corresponding information, such as the database, status, and running time.
SQL Explorer:
Display by Time Range: Select a time range to view the results from SQL Insights. You can view the Execution Duration Distribution, Execution Duration, and Executions for all SQL statements within the selected time range. You can also view detailed information for all SQL statements in the Full Request Statistics area and export it to your local machine.
NoteYou can export a maximum of 1,000 SQL logs. To obtain logs from a larger time range or a greater number of logs, you can use the Search (Audit) feature.
After you enable SQL Explorer, please allow half an hour for the Audit logs to become available.
Display by Comparison: Select the time points for which you want to compare SQL Explorer results to view the comparison results for all SQL statements based on Execution Duration Distribution, Execution Duration, and Executions. You can also view detailed comparison results in the Requests by Comparison area.
Source Statistics: Select a time range to view the source information for all SQL statements within the selected range.
SQL Review: Analyzes the workload of database clusters and the SQL statements that run on them within a selected time range and a baseline time range. This in-depth analysis 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 tables with top traffic.
Related SQL Identification: Select the metric that you want to view and click the Analysis button. After 1 to 5 minutes, you can locate the SQL statement and its detailed information whose change trend within the selected time range is most similar to that of the metric.
Traffic Replay and Stress Testing: If you are facing an upcoming short-term business peak or a database schema evolution (especially an index change), you can use the traffic replay and stress testing feature to confirm whether the database cluster needs to be scaled out, verify the actual performance in a real-world business scenario, and reduce the risk of failures after the service is published.
Security Audit: Automatically detects threats such as significant operations, SQL injection, and new access sources.
Transaction Analysis: This feature analyzes transaction details for a selected thread and time range based on hot storage data from DAS Enterprise Edition V3. It then performs statistical analysis and plots a trend chart that shows the number of different types of transactions.
Parameter description
Execution Duration Distribution: On the Execution Duration Distribution tab, you can view the distribution of execution durations of SQL queries based on the time range that you specify. The statistical data is collected every minute. The execution durations are divided into seven ranges:
[0,1] ms: indicates that the execution duration ranges from 0 ms to 1 ms. The chart shows the percentage of SQL queries whose execution durations fall within this range.(1,2] ms: indicates that the execution duration is greater than 1 ms and less than or equal to 2 ms. The chart shows the percentage of SQL queries whose execution durations fall within this range.(2,3] ms: indicates that the execution duration is greater than 2 ms and less than or equal to 3 ms. The chart shows the percentage of SQL queries whose execution durations fall within this range.(3,10] ms: indicates that the execution duration is greater than 3 ms and less than or equal to 10 ms. The chart shows the percentage of SQL queries whose execution durations fall within this range.(10,100] ms: indicates that the execution duration is greater than 10 ms and less than or equal to 100 ms. The chart shows the percentage of SQL queries whose execution durations fall within this range.(0.1,1]s: indicates that the execution duration is greater than 0.1s and less than or equal to 1s. The chart shows the percentage of SQL queries whose execution durations fall within this range.> 1s: indicates that the execution duration is greater than 1s. The chart shows the percentage of SQL queries whose execution durations fall within this range.
NoteThe section on the Execution Duration Distribution tab shows the execution time of SQL statements on the instance over time. The larger the blue area of the chart is, the healthier the instance is when the SQL statements are executed on the instance. The larger the orange and red areas of the chart are, the less healthy the instance is when the SQL statements are executed on the instance.
Execution Duration: On the Execution Duration tab, you can specify a time range to view the execution durations of SQL queries.
Full Request Statistics: You can view the details of SQL statements based on the time range that you specify. The details include the SQL text, execution duration percentage, average execution duration, and execution trend for each SQL statement.
NoteYou can calculate the execution duration percentage for the SQL statements that use a specific SQL template based on the following formula: Execution duration percentage = (Execution duration of the SQL statements that use the SQL template × Number of executions of the SQL statements)/(Total execution duration of all SQL statements × Total number of executions) × 100%. Higher execution duration percentages indicate that the database instance uses a larger number of MySQL resources to execute the corresponding SQL statements.
SQL ID: You can click an SQL ID to view the performance trend and sample data of the SQL statements that use the corresponding SQL template.
SQL Sample: On the SQL Sample tab, you can view the client that initiated each sample SQL request.
NoteThe UTF-8 character set is used to encode SQL samples.
Modify the storage duration of SQL logs
If you reduce the storage duration for SQL Explorer and Audit data, DAS immediately deletes the SQL audit logs that exceed the new storage duration. Export and save the SQL audit logs to your computer before you reduce the storage duration.
Log on to the PolarDB console. In the navigation pane on the left, click Cluster List. Select the region where the cluster is located, and click the target cluster ID to go to the cluster details page.
In the navigation pane on the left, choose .
Click Service Settings in the upper-right corner.
Modify the storage duration and click OK.
NoteIf you have enabled DAS Enterprise Edition V3, you can modify the data storage duration for different sub-features.
The storage space for SQL Explorer and Audit data is provided by DAS and does not occupy the storage space of your database cluster.
Disable SQL Explorer and Audit
After you disable the SQL Explorer and Audit feature, the SQL audit logs are deleted. Export and save the SQL audit logs to your computer before you disable the feature. When you re-enable the feature, SQL audit logs are recorded starting from the time of re-enabling.
Log on to the PolarDB console. In the navigation pane on the left, click Cluster List. Select the region where the cluster is located, and click the target cluster ID to go to the cluster details page.
In the navigation pane on the left, choose .
Click Service Settings to turn off SQL Explorer and Audit.
If you have enabled DAS Enterprise Edition V3, clear the check boxes of all features of SQL Explorer and Audit.
NoteIf you enable the audit log collection feature for PolarDB for MySQL in CloudLens for PolarDB of Simple Log Service, the SQL Explorer feature is automatically enabled for the corresponding PolarDB for MySQL cluster. Therefore, you must also disable the audit log collection feature for the PolarDB for MySQL cluster. For more information, see Enable the data collection feature.
After you disable the SQL Explorer feature, the SQL audit logs are deleted. Export the SQL records before you disable the feature. For more information about how to export SQL records, see Export SQL log records.
Click OK.
View the size and consumption details of audit logs
Log on to the Alibaba Cloud Management Console. In the upper-right corner of the page, click Fees.
In the left-side Expenses And Costs navigation pane, choose .View the cost details where the Billing Item column is sql_explorer.
On the Billing Details tab, click the Detailed Bills tab, and then search by Instance ID.View the cost details where the Billing Item column is sql_explorer.

Migrate to the new version
Currently, only database clusters in the China (Hangzhou), China (Shanghai), China (Beijing), and China (Shenzhen) regions support migration from the old version of SQL Explorer and Audit to the new version.
Log on to the PolarDB console. In the navigation pane on the left, click Cluster List. Select the Region where the cluster is located, and click the target cluster ID to go to the cluster details page.
In the navigation pane on the left, choose Logs And Audit > SQL Explorer.
In the Upgrade SQL Explorer To 'SQL Explorer And Audit' dialog box, click One-click Upgrade.
Migrate SQL Explorer and Audit data between different Enterprise Editions
Compared with Enterprise Edition V1, Enterprise Edition V2 uses a different underlying storage architecture. It uses a hybrid of hot and cold storage to reduce costs. Enterprise Edition V3 is built on the hybrid storage architecture and provides more flexible billing by itemizing fees based on the features you use. This further reduces costs.
If your database cluster supports Enterprise Edition V3, you can migrate data from DAS Enterprise Edition V1 or V2 to Enterprise Edition V3 to benefit from lower costs. For more information, see How do I migrate data between different DAS Enterprise Editions?