PolarDB for PostgreSQL SQL Explorer is a value-added service that provides health diagnostics and performance issue troubleshooting for your database.
Features
Building on full request data and security audit, Database Autonomy Service (DAS) integrates features such as Search, SQL Explorer, Security Audit, and Traffic Replay and Stress Testing. These features help you get the details of SQL statements, troubleshoot various performance issues, identify high-risk sources, and check whether your cluster specifications need to be scaled up, so that you can handle business traffic peaks.
Search feature: queries and exports SQL statements and their related information, such as the database, status, and execution time. For more information, see Audit.
NoteEnabling or disabling audit logs on the SQL Explorer and Audit console page changes the kernel parameter
log_statement.Enabling audit logs sets
log_statement = all.Disabling audit logs sets
log_statement = ddl.
SQL Explorer feature: diagnoses SQL health, troubleshoots performance issues, and analyzes business traffic. For more information, see SQL Explorer.
SQL Review feature: provides global SQL load analysis. It helps you quickly locate suspicious SQL statements in your database instances, analyze them, and get optimization suggestions. For more information, see SQL Review.
Traffic Replay and Stress Testing feature: replays traffic and runs stress tests. It helps you check whether your instance specifications need to be scaled up, so that you can handle business traffic peaks. For more information, see Traffic playback and stress testing.
Security audit feature: automatically identifies risks such as high-risk SQL, SQL injection, and new access sources. For more information, see Security Audit.
Transaction Analysis feature: with transaction analysis, you can get the transaction types, transaction counts, and transaction details of a specified process 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 feature: gets the first and last statements of the transaction that contains the SQL statement you want to analyze, so you can see whether the transaction was committed or rolled back. For more information, see Quick transaction analysis.
Supported regions
SQL Explorer and Audit is available only after you enable DAS Enterprise Edition. The regions supported by each Enterprise Edition are different. For more information, see Supported databases and regions.
Impact
Enabling SQL Explorer records information about all DQL, DML, and DDL operations. The database kernel outputs this information, so the CPU consumption of the system is extremely low.
Usage notes
To use the Search feature as a RAM user, you must grant the AliyunPolardbReadOnlyWithSQLLogArchiveAccess permission to the RAM user. For more information about how to grant permissions to a RAM user, see Create and manage RAM users.
You can also use a custom policy to grant a RAM user the permissions to use the Search feature, including the export feature. For details, see How do I use DAS as a RAM user?.
Billing
Enterprise Edition V0
The SQL Explorer feature supports only Pay-as-you-go and does not support Subscription. The related charges are billed by PolarDB.
Price
Regions in the Chinese mainland: USD 0.0013/GB/hour.
China (Hong Kong) and regions outside the Chinese mainland: USD 0.0019/GB/hour.
Later than Enterprise Edition V0
Charges related to the SQL Explorer feature are billed by Database Autonomy Service (DAS). For more information, see Billing of DAS.
Enable SQL Explorer
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select a region.
-
Click the ID of the destination cluster.
-
In the left-side navigation pane, choose .
-
Click Enable SQL Explorer.
If DAS Enterprise Edition is not enabled for your current Alibaba Cloud account, follow the on-screen instructions to enable it.
-
Click a feature tab to view related information.
-
Range View: Select a time range to view the SQL Explorer results. You can view the Execution Time Distribution, Execution Duration, and Executions for all SQL statements within the selected time range. You can also view detailed information about all SQL statements in the Full Request Statistics section and export the information to your local computer.
NoteYou can export a maximum of 1,000 SQL logs. To retrieve more SQL logs over a longer time range, use the Audit feature.
-
Display by Comparison: Select time points to compare the SQL Explorer results. You can view a comparison of the Execution Time 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.
-
Parameter descriptions
-
Execution Time Distribution: Shows the execution duration distribution of all SQL statements within the selected time range. The execution duration is divided into seven intervals and is calculated every minute:
-
[0,1]ms indicates the percentage of SQL executions where the execution duration is between 0 ms and 1 ms, inclusive. -
(1,2]ms indicates the percentage of SQL executions where the execution duration is greater than 1 ms and less than or equal to 2 ms. -
(2,3]ms indicates the percentage of SQL executions where the execution duration is greater than 2 ms and less than or equal to 3 ms. -
(3,10]ms indicates the percentage of SQL executions where the execution duration is greater than 3 ms and less than or equal to 10 ms. -
(10,100]ms indicates the percentage of SQL executions where the execution duration is greater than 10 ms and less than or equal to 100 ms. -
(0.1,1]s indicates the percentage of SQL executions where the execution duration is greater than 0.1 s and less than or equal to 1 s. -
>1s indicates the percentage of SQL executions where the execution duration is greater than 1 s.
NoteIf the Execution Time Distribution for a cluster is closer to blue, the SQL health of the instance is better. If it is closer to orange and red, the SQL health of the instance is worse.
-
-
Execution Duration: Shows the execution duration of SQL statements within the selected time range.
-
Full Request Statistics: Shows information for each type of SQL statement within the selected time range, such as the SQL text, duration percentage, average execution duration, and execution trend.
NoteDuration percentage = (Execution duration of this SQL type × Number of executions) / (Execution duration of all SQL statements × Total number of executions) × 100%. A higher duration percentage indicates that the SQL statement type consumes more cluster resources.
-
SQL ID: Click an SQL ID to view the performance trend, SQL samples, and other information for that type of SQL statement.
-
SQL Sample: Use the SQL Sample to identify which application initiated the SQL statement.
NoteSQL samples are encoded in the UTF-8 character set.
Modify the storage duration of SQL logs
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select a region.
-
Click the ID of the destination cluster.
-
In the left-side navigation pane, choose .
-
In the upper-right corner, click Service Settings.
-
Modify the storage duration, and then click OK.
If you have enabled DAS Enterprise Edition V3, you can modify the data storage duration for different sub-features.
NoteThe storage space for SQL Explorer data is provided by DAS and does not occupy the storage space of the database instance.
Export SQL records
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select a region.
-
Click the ID of the destination cluster.
-
In the left-side navigation pane, choose .
-
On the right side of the Audit tab, click Export.
-
In the dialog box that appears, select the required Export Field, specify an Export Time Range, and then click OK.
-
In the Are you sure that you want to export SQL details? dialog box, set the Task Name and CSV Separator, and then click Are you sure you want to submit the task?.
Note-
Once a task is submitted, it cannot be canceled.
-
No fees are charged if the task fails.
-
Task-related data is retained for only 7 days.
-
A maximum of 10 million records can be exported for a task. If the number of records to export exceeds 10 million, reduce the time range for the export.
-
The system requires approximately 5 minutes to process and archive the latest data. To export the latest data, wait for a few minutes and then try again.
-
-
After the export is complete, click Tasks in the upper-right corner of the SQL Explorer page. In the Actions column of the target task, click Download to download the exported file.
Disable SQL Explorer
After you disable the SQL Explorer feature, the SQL audit logs are cleared. Before you disable the SQL Explorer and SQL Audit features, export and save the SQL audit logs to your local computer. When you re-enable the SQL Explorer and SQL Audit features, SQL audit logs are recorded from the time of re-enabling.
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select a region.
-
Click the ID of the destination cluster.
-
In the left-side navigation pane, choose .
-
Click Service Settings to disable SQL Explorer and SQL Audit.
If you have enabled DAS Enterprise Edition V3, clear the check boxes for all SQL Explorer and SQL Audit features, and then click Submit.
NoteApproximately one hour after you disable the SQL Explorer and SQL Audit features, the system releases the storage space that is occupied by the SQL Explorer and SQL Audit data.
-
Select the check box to acknowledge the prompt, and then click Submit and Unsubscribe.
View the audit log size and consumption details
Log on to the Alibaba Cloud Management Console. In the upper-right corner of the page, choose Expenses.
In the left-side Expenses and Costs navigation pane, choose .View the cost details in which the Billable Item column is sql_explorer.
On the Bill Details tab, click the Detailed Bills tab, and set the search condition to Instance ID and search.View the cost details in which the Billable Item column is sql_explorer.