Benchmarking queries and the server

Suppose you want to find out which of the queries is faster. The explain plan gives you an idea, but sometimes you cannot decide based on it. You can execute them on the server and find which one is faster if the query time is in the order of tens of seconds. However, if the query time is in the order of a few milliseconds, you cannot decide based on a single execution.

You can use the mysqlslap utility (it comes along with MySQL-client installation), which emulates client load for a MySQL server and reports the timing of each stage. It works as if multiple clients are accessing the server. In this section, you will learn about the usage of mysqlslap; in later sections, you will learn about the power of ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.