Why mysqlslap Shows Smoother Results Than sysbench for SQL Performance Testing
The article explains that mysqlslap appears to produce smoother latency results than sysbench because mysqlslap reports metrics per test round rather than per individual SQL statement, leading to mis‑interpretation of Max/Avg/Min values, while sysbench can reveal per‑statement latency variations.
When benchmarking SQL statements, the author observed that results from mysqlslap look smoother than those from sysbench and investigated the reason.
Using a simple test SQL select sleep(@val := coalesce(@val, 0) + 1) from dual; , which increases the sleep time by one second on each execution, the author first ran mysqlslap . The tool reported an average of 15 seconds per round, five SQL statements per round, and therefore an average of about 3 seconds per statement. The author notes that the Max and Min values shown by mysqlslap refer to the longest and shortest round times when multiple iterations are used, not to individual statement latency, and that dividing Max by the number of statements to estimate latency is incorrect.
Next, the author used sysbench with a custom Lua script (based on bulk_insert.lua ) to run the same SQL. The sysbench output displayed a 95 percentile latency far from the mean, indicating significant variation in individual statement latency.
From these experiments the author concludes:
sysbench can expose latency anomalies of individual or groups of SQL statements.
mysqlslap measures at the round level and cannot reflect per‑statement latency; using simple division to estimate latency masks the true variability.
Thus, the smoother appearance of mysqlslap results is caused by an incorrect interpretation of its metrics rather than by the tool itself.
Tip: If the workload consists of different SQL statements, use ps_statement_avg_latency_histogram to visualize latency differences across statements.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.