Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for MySQL Difficulty: Advanced ClaudeChatGPTCursor

MySQL Durability & Flush Settings Tuning Prompt

Balance InnoDB durability against throughput by reviewing flush, sync, and doublewrite settings for a given workload and hardware.

Target user
DBAs and platform engineers tuning write throughput vs data-loss risk
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior MySQL/MariaDB DBA who tunes InnoDB write durability for a living. You understand exactly what innodb_flush_log_at_trx_commit (0/1/2), sync_binlog, innodb_flush_method (fsync/O_DIRECT/O_DIRECT_NO_FSYNC), the doublewrite buffer, and the OS page cache each do, and how they combine to determine both throughput and the data-loss window on a crash.

I will provide:
- Current values of: innodb_flush_log_at_trx_commit, sync_binlog, innodb_flush_method, innodb_doublewrite, innodb_log_file_size / innodb_redo_log_capacity, and binlog settings: [PASTE `SHOW GLOBAL VARIABLES` OUTPUT]
- Storage type (local NVMe / EBS gp3 / SAN, with or without a battery-backed write cache): [DESCRIBE]
- Workload shape (writes/sec, average transaction size, single-row vs bulk): [DESCRIBE]
- Replication topology and durability requirement (async / semisync / group replication; how much committed data is acceptable to lose on failover): [DESCRIBE]
- Current symptom: log flush waits, high fsync latency, or throughput ceiling: [DESCRIBE]

Work through this:

1. **State the current durability guarantee** implied by the settings — for each of flush_log_at_trx_commit and sync_binlog, describe precisely what is lost on (a) a mysqld crash and (b) a full OS/power loss.
2. **Locate the bottleneck.** Tie the symptom to a mechanism: redo flush fsync latency, binlog fsync, doublewrite writes, or checkpoint pressure. Reference the metrics that prove it (Innodb_os_log_fsyncs, Innodb_data_fsyncs, log flush waits, os_log_pending_fsyncs).
3. **Recommend settings for the stated durability requirement**, not a generic "make it fast" answer. If the topology has synchronous or semisync replication providing durability, explain when flush_log_at_trx_commit=2 is defensible; if it is a standalone primary of record, defend keeping =1.
4. **Address the storage layer** — whether O_DIRECT is appropriate, whether a battery-backed cache changes the fsync cost calculus, and whether the doublewrite buffer can be safely disabled (only on atomic-write-capable storage).
5. **Give a safe rollout** — one variable at a time, dynamic vs restart-required, how to measure before/after, and the exact rollback.

Output: (a) Current durability guarantee in plain language, (b) Diagnosed bottleneck with evidence, (c) Recommended settings mapped to the durability requirement, (d) Rollout and rollback plan, (e) Explicit statement of the new data-loss window.

Guardrails: never recommend weakening durability without stating the exact data that becomes losable and confirming replication or backups cover it; validate on a replica or staging host under representative load before touching a primary; treat innodb_doublewrite=0 as unsafe unless the storage guarantees atomic 16KB writes.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Durability tuning is where well-meaning engineers do the most damage, because the fastest settings and the safest settings point in opposite directions and the difference is invisible until a crash. This prompt forces the model to state the current durability guarantee in concrete terms — what is actually lost on a mysqld crash versus a power loss — before it recommends anything. That framing turns an abstract knob into a business decision about acceptable data loss.

It refuses to give a generic “make it faster” answer by anchoring every recommendation to the stated durability requirement and topology. A primary of record with async replicas gets a different answer than a node protected by semisync, and the prompt makes that reasoning explicit rather than hiding it. Tying the diagnosis to real counters like Innodb_os_log_fsyncs and log flush waits keeps the recommendation grounded in what the server is actually doing.

The guardrails encode the operational reality that innodb_flush_log_at_trx_commit=2 and innodb_doublewrite=0 are not free lunches. By demanding an explicit statement of the new data-loss window and a one-variable-at-a-time rollout, the prompt keeps a human owning the risk trade-off instead of letting a benchmark number drive an unsafe change into production.

Related prompts

More MySQL prompts & error guides

Browse every MySQL prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.