MySQL

How to use SQL_NO_CACHE?

The SQL_NO_CACHE option is used just after the SELECT statement to specify that no-cache should be applied to a query. This feature is particularly useful when a developer wants to estimate the loading time of a query without the result being affected by caching.

This option is therefore very useful when you want to work on optimizing the loading time, especially when a request has been detected as being particularly slow.
 

Syntax:

This option is used in an SQL query via the following syntax:

SELECT SQL_NO_CACHE * FROM table;

This SQL query example is simple and shows a list of all columns for the table named “table”.
 
[st_adsense]  

Note:

There is also an option called SQL_CASH that allows you to get the result of a SQL query that is already cached.
 

Tip:

There are other methods to get the result of a SQL query without having the result cached. For example, it is possible to reference the current date or time to ensure that the result is unique.
 
Example:

SELECT *, NOW() FROM table;

In this example, the NOW() function is used to reference the current date and time.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More [st_adsense]

Leave a Reply

Your email address will not be published. Required fields are marked *