Skip to content
About
Main content

Tune a buffer pool

The decision

A database keeps recently used disk pages in a in memory, so a page read twice is read from disk once. When the pool is full, a replacement policy decides which page to evict. How the pool performs depends far more on the workload than on the policy's sophistication. What should this pool do?

You will end with a replacement policy, the pool's usable size under load, and the settings that matter more than either.


Before you choose

Use declared access patterns if your engine has them

If operators can tell the pool "this is a one-time scan": use that. It beats every adaptive policy, because the operator knows what the policy can only guess. Check whether your engine exposes it before tuning any policy.


Decide

1

What dominates the workload?

Why

A scan touches every page once, so no replacement policy can keep useful pages while it runs: the scan evicts them. Point lookups on skewed keys reuse a small hot set, so even a small pool captures most of the benefit.

2

Do more than a few dozen cores hit the pool at once?

Why

Past a few dozen cores, the synchronization on every hit costs more than a better policy saves. Clock updates almost nothing on a hit, so it wins regardless of what hit-rate studies say.

3

Is it a mix of scans and point lookups?

Why

A mixed workload is the only case where a policy that tracks both recency and frequency earns its extra metadata.


Where you can land

Isolate scans in a ring buffer

Use it when scans dominate.

Give each scan a small private ring of pages, so it cannot evict the shared hot set.

Clock

Use it when many cores share the pool, or the workload is point lookups.

Approximates least-recently-used with one reference bit per page and almost no work on a hit.

Before you size it: the hit-rate curve flattens quickly under skew, so compute the the next gigabyte buys before buying it.

2Q or ARC

Use it when scans and point lookups mix, and core count is modest.

Separates pages seen once from pages seen repeatedly, so a scan cannot flush the frequently used ones.

What it costs: extra metadata and more work per hit.


Whichever you land on

1

Find the usable size under load

Usable size = configured size − pinned pages − not yet written. That, not the configured number, is what memory rationing must be given.

2

Check the cleaner keeps up with writes

If dirty pages accumulate faster than the background writer flushes them: the pool fills with pages it cannot evict, and reads stall. The fix is upstream of the replacement policy: write throughput, flush settings.

3

Back the pool with huge pages, and turn transparent huge pages off

Explicit cut address-translation misses for a large pool; the kernel's automatic version causes stalls. It is a yes-or-no setting with a large effect, and the one most often left at its default.