Skip to main content

Module plan_cache

Module plan_cache 

Source
Expand description

v6.3.0 — Engine-level plan cache.

Caches the post-prepare() Statement (clock-rewritten, ORDER-BY-position-resolved, JOIN-reordered) keyed on the raw SQL string. Hit path skips parse + clock rewrite + JOIN reorder — for a 5-table JOIN that’s the dominant cost.

statistics_version and source_tables are stored on the entry so v6.3.1 can invalidate selectively when ANALYZE bumps the stats version, or when DDL changes one of the source tables.

describe_columns is reserved for v6.3.3 Describe pre-Execute — v6.3.0 leaves it empty.

Cache is bounded by PLAN_CACHE_MAX_ENTRIES (256). Eviction is LRU via a VecDeque<String> move-to-back on get. Both get and insert are sub-microsecond at 256 entries.

Structs§

PlanCache
PreparedPlan
One cached plan. The cached stmt is the same one Engine::prepare() would return — parse + clock rewrite + ORDER-BY position resolution + JOIN reorder all already applied.

Functions§

collect_source_tables
Walk a Statement and collect every distinct table name referenced by its FROM clauses (including JOIN tables and subquery FROMs). Used by PreparedPlan::source_tables for v6.3.1 selective invalidation.