MySQL Kill Query
MySQL Kill Query is a SQL statement in the MySQL Specific category. MySQL: terminates a connection or a running query. KILL QUERY only kills the query, not the connection. The syntax is KILL [CONNECTION | QUERY] process_id;. It returns connection killed. A typical example: -- Find running queries: SHOW PROCESSLIST; -- Id: 123, Time: 300, Info: SELECT * FROM huge_table... -- Kill the connection: KILL 123; -- Kill only the query (not connection): KILL QUERY 123; -- Connection stays alive, can run more queries -- Kill queries from a specific user: SELECT CONCAT('KILL ', id, ';') AS kill_query FROM information_schema.PROCESSLIST WHERE user = 'long_running_user' AND time > 100; -- Requires PROCESS privilege or SUPER A close relative is AUTO_INCREMENT, which mySQL auto-generates sequential integer values for this column. Commonly used with PRIMARY KEY. A close relative is ENGINE, which specifies the MySQL storage engine. InnoDB (default) supports transactions and foreign keys. MyISAM is faster for read-heavy.