The world's most popular open source database
Two query cache-related options may be specified in
SELECT statements:
The query result is cached if it is cacheable and the
value of the
query_cache_type system
variable is ON or
DEMAND.
SQL_NO_CACHE
The query result is not cached.
Examples:
SELECT SQL_CACHE id, name FROM customer; SELECT SQL_NO_CACHE id, name FROM customer;


User Comments
Note: Using SQL_NO_CACHE does not bypass the cache mechanism, so it is not a reliable way to time query speed. All it does is tell the server not to cache the results of the specific query you're sending.
If you've already executed the query without the option, some other time, that cached result will be fetched.
I do not agree with the comment above because of 2 reasons:
1 row in set (7.98 sec)1.) The hash is different when I have SELECT SQL_NO_CACHE * ... and SELECT * ... So the result will never match.
2.) See test sequence below:
mysql> select count(*) from City c1 join City c2 on c1.name = c2.name;
mysql> select count(*) from City c1 join City c2 on c1.name = c2.name;
1 row in set (0.00 sec)
mysql> select sql_no_cache count(*) from City c1 join City c2 on c1.name = c2.name;
1 row in set (8.04 sec)
mysql> select sql_no_cache count(*) from City c1 join City c2 on c1.name = c2.name;
1 row in set (8.46 sec)
Add your own comment.