SELECT SQ_CACHE * FROM TABLE where ID=1
Questions:
- if a new row is added to the table, will be cache still be maintained?
- if a row other than
ID=1updates still my cache be maintained? - i know if same row is updated cache is lost.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
* Aside from some corner-cases or bugs maybe.
The “short” answer (note: specific to MySQL) would be: AFAIK MySQL caches on table level granularity; so any change on that table would invalidate all cached results for that table. Other than that, only deterministic queries will get cached, transactions might bypass/invalidate caches, the query cache doesn’t support prepared statements, queries must be absolutely exactly be the same for the cache to kick in at all (so an extra space in a query would cause a cache miss) and subqueries aren’t supported. And then there are still other factors involved. Maybe some things have changed in more recent versions but these are, some (not all!) of the factors that used to be involved. Correct me if I’m wrong.