The Server Query Cache (QC) is a well-known feature of MariaDB Server–it caches SQL statements and the corresponding result sets. Today we have faster, solid-state disks and more RAM, so the Query Cache is less important. Reducing reliance on cache alleviates its negative effects, such as mutex blocking. By Anders Karlsson.
A mutual exclusion object (mutex) is a programming object that allows multiple program threads to share a resource (such as a folder) but not simultaneously. Mutex is set to unlock when the data is no longer needed or when a routine is finished. Mutex creates a bottleneck effect. The blocking means only one query can look at the Query Cache at a time and other queries must wait. A query that must wait to look in the cache only to find it isn’t in the cache will be slowed instead of being accelerated.
The article then in some detail describes:
- Query Cache Flags
- Query Cache Concerns
- The MaxScale Query Filter
- Mutex Work Around
- Fixing the Query Cache
… and more. Everything is demonstrated in provided code examples. Plus instructions how to test. Good read!
[Read More]