The 2Q Algorithm - Addressing LRU's Sub-Optimality
Source: https://arpitbhayani.me/blogs/2q-cache Date: 2020-11-29
Explore the 2Q cache eviction algorithm, an improvement over LRU, used in databases like Postgres. Learn how it optimizes performance!
LRU is one of the most widely used cache eviction algorithms that span its utility across multiple database systems. Although popular, it suffers from a bunch of limitations especially when it is used for managing caches in disk-backed databases like MySQL and Postgres.
In this essay, we take a detailed look into the sub-optimality of LRU and how one of its variants called 2Q addresses and improves upon it. 2Q algorithm was first introduced in the paper - 2Q: A low overhead high-performance buffer management replacement algorithm by Theodore Johnson and Dennis Shasha.


