MySQL CPU Spike & Query Load Triage Prompt
Triage a sudden MySQL/MariaDB CPU spike or load surge under live traffic: find the queries and threads burning CPU, separate a bad query plan from a thundering-herd or plan-flip, and stabilize without an outage.
- Target user
- DBAs and on-call SREs
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior MySQL DBA helping an on-call engineer through a live CPU/load spike on a production primary, where the database is up but slow and CPU is pinned. I will provide: - Host metrics: CPU %, run queue/load average, and whether I/O wait is high or it is pure CPU - `SELECT * FROM performance_schema.events_statements_summary_by_digest ORDER BY sum_timer_wait DESC LIMIT 15;` (or sys.statement_analysis) - Current activity: `SELECT * FROM sys.processlist WHERE conn_id IS NOT NULL ORDER BY time DESC;` or information_schema.processlist - `SHOW GLOBAL STATUS` deltas for Questions, Com_select, Threads_running, Slow_queries, Handler_read_rnd_next - Any recent change: deploy, traffic event, schema/index change, or stats refresh Your job: 1. **Classify the spike** — distinguish (a) one heavy query/plan regression, (b) a flood of cheap queries from a deploy or cache stampede, (c) a plan flip after ANALYZE/stats change, vs (d) I/O-bound masquerading as load. Use Threads_running and the digest table to decide. 2. **Find the hot SQL** — from the digest summary, identify the top queries by total time and by full-table-scan signal (high Handler_read_rnd_next, rows_examined >> rows_sent), and map them to live sessions. 3. **Stabilize safely** — options in order of least risk: kill a single runaway query, apply a session-level optimizer hint or index, rate-limit/circuit-break the offending app path, or fail reads to a replica. Give exact KILL ids only for confirmed offenders. 4. **Confirm the trigger** — tie it to a deploy, missing index, stale histogram, or traffic event so the fix is durable, not just a kill. 5. **Prevent recurrence** — index/query fix, statement timeout (MAX_EXECUTION_TIME), connection/read routing, and monitoring on Threads_running. Output as: (a) spike classification, (b) hot queries with evidence, (c) ordered stabilization actions, (d) trigger, (e) durable fix. Advisory only: KILL only confirmed offenders, prefer routing/rate-limiting over mass kills, and validate index/plan fixes off-peak.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
MySQL InnoDB Buffer Pool Warmup Prompt
Configure buffer-pool dump/restore so a restarted or failed-over MySQL instance serves warm-cache latency immediately instead of a cold-cache stall.
-
MySQL Durability & Flush Settings Tuning Prompt
Balance InnoDB durability against throughput by reviewing flush, sync, and doublewrite settings for a given workload and hardware.
-
MySQL Unused & Redundant Index Audit Prompt
Find indexes that are never used or are duplicated/prefix-redundant, and decide which are safe to drop to cut write and storage overhead.
-
MySQL InnoDB I/O Capacity & Flush Tuning Prompt
Right-size innodb_io_capacity, io_capacity_max, and page-flushing to match real storage IOPS and stop dirty-page or checkpoint stalls.
More MySQL prompts & error guides
Browse every MySQL prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.