Using sql_cache in Mysql query

Asked

Viewed 111 times

3

When I learned Mysql, I was recommended to use the expression sql_cache after the SELECT, something like that:

"SELECT sql_cache * FROM tabela..."

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

What is the function to use sql_cache? Is it right to use it or makes no difference?

1 answer

2


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

But stay tuned for Mysql version as from version 5.7 it will be discontinued, and in version 8 it will be removed.

SQL_CACHE

Usually, you shouldn’t have to wear this at all. SQL_CACHE is only required if queries are not cached by default, and they are not in the default configuration of the application, as in the case of 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 cache internally as wordpress which works with plugins specific to this end, for this reason the mysql tends to remove this function.

Valley resaltar if in your case its application in asp classico has this cache storage.

Here is an explanation in the documentation of Mysql, I use both methods and the difference is remarkable in processing.

  • Cool. I can see that.

  • 1

    @DVD I’m even studying about it because I maintain an old system that has some very heavy query and now I’m studying about cache on php, but as the documentation mentions I believe that most languages should provide cache.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.