pub struct PagePool { /* private fields */ }Expand description
The pages every reader of one database keeps, under one budget in bytes.
A reader lives as long as the database does, so the pages it holds are what the next query finds already in memory. They used to be four stripes a column, oldest out first, which on TPC-H SF1 meant every query read every page of lineitem off the file again and paid the system call for it. Keeping every page there costs 38 MB and took a third of the system time off the suite.
So the question is no longer how many stripes a column keeps but how many bytes the database does, and one budget answers it for every reader at once. A table nobody queries gives its pages up to one that is being queried, which a count per column cannot do.
Pages leave by the clock. Each has a bit a read sets, and when the pool is over budget it walks from the oldest: a page with the bit set loses the bit and goes round again, and a page without it goes. That keeps what is read over and over and lets a page one scan read once go first.
The old count is still a floor. A column never gives up a page while it holds four or fewer, because a scan whose workers evict each other’s pages reads a quarter of a megabyte for every part it takes, and a budget of zero is the cache as it was before the pool existed.