Home > Database > Mysql Tutorial > body text

How to Disable Query Caching for Accurate Speed Testing in MySQL?

Susan Sarandon
Release: 2024-11-19 06:53:02
Original
264 people have browsed it

How to Disable Query Caching for Accurate Speed Testing in MySQL?

Disable Query Caching for Accurate Speed Testing in MySQL

When conducting performance tests on MySQL queries, caching can significantly distort results, obscuring the true execution speed. This article addresses the question of how to disable caching for specific queries in MySQL.

To prevent MySQL from caching the results of a query, use the SQL_NO_CACHE option. This directive, introduced in MySQL 5.7, explicitly instructs the optimizer to bypass the cache and retrieve data directly from the database.

Example:

SELECT SQL_NO_CACHE * FROM table_name;
Copy after login

By incorporating this option into the query, you effectively disable server-side caching for that particular execution. However, it's important to note that other factors like operating system and disk caching can still impact performance. These caches external to MySQL are harder to circumvent.

The above is the detailed content of How to Disable Query Caching for Accurate Speed Testing in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template