PolarDB-X instance sessions
PolarDB-X allows you to view the sessions of an instance and their statistics. If your instance experiences a sudden CPU spike, a surge in active sessions, or an increased response time, you can use the 10s SQL Analysis feature to analyze real-time SQL queries.
Session management
-
Log in to the PolarDB-X console.
-
In the upper-left corner of the page, select the region of your target instance.
-
On the Instances page, click the PolarDB-X 2.0 tab.
-
Find the target instance and click its ID.
-
In the navigation pane on the left, choose . The Instance Sessions and Session Statistics sections provide detailed information.
-
In the Instance Sessions section, you can perform the following operations:
-
View details about instance sessions, such as exceptions, active sessions, maximum execution time, CPU utilization, and connection usage.
-
10s SQL Analysis: Click 10s SQL Analysis in the upper-right corner of the page. In the dialog box, you can view SQL statistics, the slow query log, and an SQL overview for the 10-second period. For more information, see 10s SQL Analysis.
-
SQL throttling: Click SQL Throttling. In the dialog box, configure parameters to throttle SQL queries that meet specific conditions. For more information, see SQL throttling.
-
Optimize: Click Optimize to begin optimizing the target instance sessions. For more information, see SQL Optimization.
-
Export active sessions.
-
Terminate sessions.
WarningTerminating sessions can cause service interruptions. Proceed with caution.
-
-
In the Session Statistics section, you can perform the following operations:
-
View a session summary, which includes the total number of sessions, running sessions, and the longest session execution time. You can also view the number of total and active sessions grouped by user, access source, or database.
NoteUse these statistics to identify the total number of sessions, active sessions, the longest session execution time in seconds, the number of sessions running for more than 3 seconds, and queries that do not use an index.
-
Export statistics by summary, user, access source, or database.
-
-
SQL throttling
-
Log in to the PolarDB-X console.
-
In the upper-left corner of the page, select the region of your target instance.
-
On the Instances page, click the PolarDB-X 2.0 tab.
-
Click the instance ID. In the navigation pane on the left, choose .
-
Click SQL throttling. In the SQL throttling dialog box, configure the following parameters.
Parameter
Description
Throttling Mode
Select one of the following throttling modes:
-
Throttled by Keywords: Throttles SQL queries that contain the specified keywords.
-
Throttled by SQL Template ID: Throttles SQL queries based on their template ID. The template ID is an 8-character hexadecimal string which you can find in SQL logs, sessions, or the results of an EXPLAIN statement. This option is available only for PolarDB-X Enterprise Edition instances.
-
Throttled by Execution Duration: Throttles SQL queries based on their execution time. After you create a rule in this mode, if the execution time of a specific SQL type exceeds the configured threshold, the template ID for that SQL type is automatically added to the throttling rule. The queries are then executed based on the specified maximum concurrency. This option is available only for PolarDB-X Enterprise Edition instances.
NoteYou can also set a maximum number of throttled SQL template IDs. When this limit is reached, the system stops creating throttling rules for other SQL queries.
SQL Type
Select the SQL type. Valid values: SELECT, UPDATE, DELETE, and INSERT.
Maximum Concurrency
The maximum concurrency of throttled SQL queries on a single node.
Throttling Duration
The duration for which the SQL throttling rule is active. SQL throttling is an emergency measure. We recommend that you set the duration based on your business needs and disable the rule when it is no longer needed.
SQL Keywords
Keywords in the SQL queries to throttle. This parameter is required when Throttling Mode is set to Throttled by Keywords. Separate multiple keywords with tildes (
~). Example:For the original statement
SELECT * FROM test where name = 'das', the keywords can beSELECT~FROM~test~where~name. You can also include specific parameter values, such as adding~das.Database Account for Throttled SQL
The database account that owns the throttled SQL queries. This parameter is required when Throttling Mode is set to Throttled by Keywords or Throttled by SQL Template ID.
Template ID
The template ID of the SQL queries to be throttled. This parameter is required when Throttling Mode is set to Throttled by SQL Template ID. Separate multiple template IDs with commas (
,).SQL Execution Time
The threshold for the SQL execution time. If an SQL query's execution time exceeds this threshold, the system automatically adds the template ID of that SQL type to the throttling rule. This parameter is required when Throttling Mode is set to Throttled by Execution Duration.
Throttled SQL Template ID Limit
The maximum number of SQL template IDs that can be throttled based on execution duration. When this limit is reached, the system no longer creates throttling rules for other SQL queries that exceed the execution time threshold. This parameter is required when Throttling Mode is set to Throttled by Execution Duration.
-
-
Click Create.
After you create a SQL throttling rule, you can view its status in the SQL throttling list.
The SQL throttling list includes Running and Finished tabs, and displays fields for each rule, such as Throttling Mode, Maximum Concurrency, Throttling Duration, Start Time, Remaining Time (s), Status, Throttling Rule, Number of Throttled SQL Templates, and Number of Throttled SQLs.
If you need to Close or Modify a throttling rule ahead of schedule, click Close or Modify in the Operation column for the target rule.
10s SQL analysis
This feature analyzes real-time SQL queries on your instance by running the show processlist command once per second for 10 seconds. The system then aggregates and analyzes these results, revealing the most frequently executed and slowest SQL queries from that period.
-
Log in to the PolarDB-X console.
-
In the upper-left corner of the page, select the region of your target instance.
-
On the Instances page, click the PolarDB-X 2.0 tab.
-
Find the target instance and click its ID.
-
In the navigation pane on the left, choose .
-
Click the 10s SQL Analysis button.
-
After 10 seconds, the analysis results show the most frequently executed SQL queries and any slow SQL queries from that period.