Mysql Kill A Query Today

Almost six minutes. That single query was hogging the CPU, locking critical rows, and starving the checkout service.

She SSH’d into the production database server and ran the usual triage:

KILL <connection_id>; -- kills the entire connection, not just the query She never forgot that 2 AM wakeup. And from then on, every SELECT on large tables had to justify its indexes in the design review. “With great SELECT comes great responsibility — and the ability to KILL QUERY when responsibility fails.” mysql kill a query

Killing it was the only immediate option. No time for a graceful shutdown.

She quickly checked the execution plan (EXPLAIN) — sure enough, no index on created_at and a full table scan on products with a wildcard LIKE . A perfect storm. Almost six minutes

The next morning, Maya added a monitoring alert for queries running longer than 60 seconds. She also taught the dev team how to catch themselves:

Almost instantly, CPU usage dropped from 98% to 12%. The API errors stopped. Her phone went quiet. And from then on, every SELECT on large

-- Find long-running queries SELECT id, user, time, state, info FROM information_schema.PROCESSLIST WHERE command != 'Sleep' AND time > 60; -- Kill one KILL QUERY <id>;

Almost six minutes. That single query was hogging the CPU, locking critical rows, and starving the checkout service.

She SSH’d into the production database server and ran the usual triage:

KILL <connection_id>; -- kills the entire connection, not just the query She never forgot that 2 AM wakeup. And from then on, every SELECT on large tables had to justify its indexes in the design review. “With great SELECT comes great responsibility — and the ability to KILL QUERY when responsibility fails.”

Killing it was the only immediate option. No time for a graceful shutdown.

She quickly checked the execution plan (EXPLAIN) — sure enough, no index on created_at and a full table scan on products with a wildcard LIKE . A perfect storm.

The next morning, Maya added a monitoring alert for queries running longer than 60 seconds. She also taught the dev team how to catch themselves:

Almost instantly, CPU usage dropped from 98% to 12%. The API errors stopped. Her phone went quiet.

-- Find long-running queries SELECT id, user, time, state, info FROM information_schema.PROCESSLIST WHERE command != 'Sleep' AND time > 60; -- Kill one KILL QUERY <id>;

SUPPORT CENTER
m_key:ZyjefvgE8GPporHyfgKl