I am new to DBA stack exchange & this is my first question. Kindly help me in finding a low level documentation for Query Cache module in MySQL since I am planning to work with the source code of Query Cache. I googled a lot but I was provided with only high level details. Is it available in MySQL website (I tried but not an exhaustive search)? Please help me.
2 Answers
This is the best documentation available for the query cache:
I am not kidding, the header of that file contains the most detailed overview I have ever found. Next thing is the own code, which is on the very same link.
There is a query cache chapter on this book, and this other book, but only 4-5 paragraphs, in the context of its relation with the handlers interface.
Apart from that, you should read the general internals code guide.
-
1
-
[OFFTOPIC] I won't be the one telling that Dijkstra is wrong, but I consider c2.com/cgi/wiki?GoTo a value discussion, specifically for low-level programs like Linux or MySQL. As it says: The apprentice uses it without thinking. The journeyman avoids it without thinking. The master uses it thoughtfully.– jynusCommented Jul 16, 2014 at 21:57
-
1My comment was tongue-in-cheek! I read somewhere that "C allows you to do very stupid things because it allows you to do very clever things". I'm sure that the MySQL programmers would have come up with a better solution if there was one for this particular piece of code.– VéraceCommented Jul 16, 2014 at 22:14
I hope you are sitting down because I have a hardcore reality check for you.
InnoDB and the MySQL Query Cache have been fiercely known to be at war with one another.
I am a staunch advocate of disabling the Query Cache with a DB that mostly or all InnoDB.
Here are my posts where I discuss why:
Sep 05, 2012
: Is the overhead of frequent query cache invalidation ever worth it?Sep 26, 2013
: query cache hit value is not changing in my databaseDec 23, 2013
: MySQL with high CPU and memory usageApr 17, 2014
: How to decide whether to enable MySQL query cache using InnoDBJun 07, 2014
: Why query_cache_type is disabled by default start from MySQL 5.6?Jun 11, 2014
: Increased query_cache_size, Queries slowed drastically on increased traffic
Why is this worth bringing up at this time ? You said you are planning to work with the source code of Query Cache. If you do manage to control the Query Cache's underlying data structure, mechanisms, and algorithms, then you will affect the way InnoDB invalidates query cache entries (or at least the speed it invalidates).
In many cases, knowing the size of result sets and a properly sized Query Cache can help you tune query_cache_min_res_unit and the query_cache_size.This can minimize InnoDB's heavy-handed interaction and overall query performance. This would be a greater endeavor that trying to change the Query Cache at the source code level.
If you must do so, you should read through these posts from mysqlperformanceblog.com. That way, when you jump into the ocean, you don't encounter any hidden rocks.