Stops a running SQL statement or terminates a database connection in PolarDB-X 1.0.
Prerequisites
Before you begin, ensure that you have:
A PolarDB-X 1.0 instance
An active connection to the PolarDB-X 1.0 database (see Step 4: Connect to PolarDB-X)
How it works
PolarDB-X routes SQL through two layers: a logical layer that manages client connections, and a physical layer that executes SQL on the underlying storage nodes. The KILL statement targets each layer differently:
| Statement | Effect |
|---|---|
KILL PROCESS_ID | Stops all logical and physical SQL on a connection, then closes the connection |
KILL 'PHYSICAL_PROCESS_ID' | Stops a specific physical SQL statement without affecting the connection |
KILL 'ALL' | Stops all running physical SQL statements in the database |
PolarDB-X 1.0 does not supportKILL QUERY. In standard MySQL,KILL QUERYstops the current statement while keeping the connection open. In PolarDB-X 1.0, useKILL PROCESS_IDto stop a connection and all its associated SQL, orKILL 'PHYSICAL_PROCESS_ID'to stop a specific physical statement.
Stop a connection
To stop all SQL on a connection and close it, run:
KILL PROCESS_IDGet PROCESS_ID by running SHOW [FULL] PROCESSLIST.
Example workflow:
List active connections and find the target process:
SHOW FULL PROCESSLIST;Use the
Idvalue from the output to stop the connection:KILL 100;
Stop a physical SQL statement
To stop a specific physical SQL statement without closing the connection, run:
KILL 'PHYSICAL_PROCESS_ID'Get PHYSICAL_PROCESS_ID by running SHOW PHYSICAL_PROCESS_ID.
PHYSICAL_PROCESS_ID is a string, not a number. Always enclose the value in single quotation marks.Example:
mysql> KILL '0-0-521570';
Query OK, 0 rows affected (0.01 sec)Stop all physical SQL statements
To stop all running physical SQL statements in the database, run:
KILL 'ALL'