Using sql_cache in MySQL query

3

When I learned MySQL, I was advised to use the expression sql_cache after SELECT , something like this:

"SELECT sql_cache * FROM tabela..."

Since then I started to use this in my codes, but it was never very clear to me what that is for, if it has to do with cache, it accelerates the query, anyway. I also never noticed any difference by hiding such query expression. I use Classic ASP.

What is the function of using sql_cache ? Is it okay to use this or does it make no difference at all?

    
asked by anonymous 25.10.2017 / 20:54

1 answer

2

Yes it has an impact on the query if it is done again, and can precede with two types those that store the query in cache and a second one that does not store and are used with low frequency.

  

But watch out for the version of MySql since from version 5.7 it will be discontinued, and version 8 will be removed.

     

SQL_CACHE

Generally, you should not have to use this at all. SQL_CACHE is only required if queries are not cached by default, and are not in the default application configuration, such as wordpress.

  

NO_SQL_CACHE

It is useful if you know that a specific query will not be used again in the near future, especially if the result set is large. The goal is to avoid caching confusion with results that will not be needed again.

Applications tend to provide the cache internally as wordpress that works with specific plugins for this purpose, so mysql tends to remove this function.

It's worth highlighting if in your case your application in asp classico has this cache storage.

Here's an explanation in the MySql documentation, I use both methods and the difference is noticeable in processing.

    
25.10.2017 / 21:06