Skip to content

[cross-schema] Introduce PlanCacheSchemaKey and multi-schema QueryCacheKey - #4442

Draft
arnaud-lacurie wants to merge 4 commits into
mainfrom
apple/arnaud-lacurie/cross-schema/pr1
Draft

[cross-schema] Introduce PlanCacheSchemaKey and multi-schema QueryCacheKey#4442
arnaud-lacurie wants to merge 4 commits into
mainfrom
apple/arnaud-lacurie/cross-schema/pr1

Conversation

@arnaud-lacurie

@arnaud-lacurie arnaud-lacurie commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Introduces PlanCacheSchemaKey — a stable key component derived from a set of (schemaName, schemaVersion) pairs — so that a cached plan is invalidated when any participating secondary schema changes
  • Extends QueryCacheKey to carry the secondary-schema set alongside the primary schema, giving each multi-schema query its own cache slot
  • No behaviour change for single-schema queries; the secondary set is empty and the key is identical to before

Test plan

  • Plan cache unit tests pass
  • Multi-schema queries get distinct cache entries from single-schema queries
  • No regression in single-schema plan-cache hit rate

Replace raw String primary cache key with PlanCacheSchemaKey holding an
ImmutableSortedSet of schema names. Replace single schemaTemplateVersion
in QueryCacheKey with ImmutableSortedMap<String,Integer> schemaVersions,
enabling cross-schema plan cache keying.

Affects: PlanCacheSchemaKey (new), QueryCacheKey, RelationalPlanCache,
AstNormalizer.NormalizationResult, PlanGenerator, and their tests.
@arnaud-lacurie
arnaud-lacurie force-pushed the apple/arnaud-lacurie/cross-schema/pr1 branch from f0c1db0 to 90fd710 Compare August 14, 2026 16:48
@arnaud-lacurie arnaud-lacurie changed the title Introduce PlanCacheSchemaKey and multi-schema QueryCacheKey (cross-schema 1/6) [cross-schema] Introduce PlanCacheSchemaKey and multi-schema QueryCacheKey Aug 14, 2026
Checkstyle RedundantImport: PlanCacheSchemaKey lives in the same
package as this test class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant