Home  >  Article  >  Database  >  How to Disable Query Caching for Accurate Speed Testing in MySQL?

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

Susan Sarandon
Susan SarandonOriginal
2024-11-19 06:53:02265browse

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;

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!

Statement:
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