Databases 3 min read

Which Is More Accurate: MySQL Binlog Execution Time or Slow Query Log?

The article investigates the discrepancy between MySQL binlog execution time and slow query log duration for an INSERT statement, conducts an experiment with artificial I/O latency, and explains why the slow log provides a more complete measurement of query execution.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Which Is More Accurate: MySQL Binlog Execution Time or Slow Query Log?

During a learning session, an INSERT statement was observed to take 2 seconds according to the binlog, while the slow query log reported a query_time of 10 seconds, raising the question of which measurement is more accurate.

To explore this, the authors set up a slow I/O device that adds a 2000 ms delay to both read and write operations, then executed the INSERT on a test database. Screenshots show the binlog reporting a 2‑second execution and the slow log reporting 10 seconds, mirroring the original observation.

The experiment suggests that the slow query log is more accurate because the binlog execution time does not include the latency incurred when flushing the binlog to disk.

The underlying principle is that a MySQL statement passes through several stages: start, general log, parsing, execution (during which binlog events are generated), binlog flush, and slow‑log recording. The binlog’s execution time covers only the period from start to event generation (steps 1‑4), whereas the slow log measures the full duration from start to completion of all steps (steps 1‑6). By artificially delaying the binlog flush step, the difference becomes evident.

In practice, comparing these two timestamps can help operators diagnose whether binlog flushing is a performance bottleneck.

monitoringperformanceDatabaseMySQLbinlogSlow Query Log
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.