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.
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.
Apart from that, you should read the general internals code guide.
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 database
Dec 23, 2013: MySQL with high CPU and memory usage
Apr 17, 2014: How to decide whether to enable MySQL query cache using InnoDB
Jun 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.