Skip to content

catalog: share nested database and schema maps - #41319

Draft
aljoscha wants to merge 1 commit into
aljoscha/ddl-timeline-hold-coalescingfrom
aljoscha/ddl-nested-catalog-maps
Draft

aljoscha wants to merge 1 commit into
aljoscha/ddl-timeline-hold-coalescingfrom
aljoscha/ddl-nested-catalog-maps

Conversation

@aljoscha

@aljoscha aljoscha commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Catalog snapshots share their outer maps, but modifying a database or schema still clones ordinary nested maps. The copying cost grows with the number of schemas and objects, even for one CREATE or DROP.

Description

Use the existing persistent ordered-map implementation for database schema lookups and schema item, function and type namespaces. Mutation retains copy-on-write snapshot isolation and deterministic iteration. The SQL catalog's schema-ID interface returns an iterator instead of exposing a concrete map type, so the local compiler catalog can retain its own representation.

Stacked on #41301.

Verification

Adds a catalog-boundary regression covering snapshot isolation across database, ambient and temporary schemas, separation of item/function/type namespaces, schema-name ordering, and preservation of children across durable schema and database replacements. Existing SQL tests cover same-name function/type/item lookup (regproc.slt, regtype.slt, types.slt), schema search paths and temporary objects.

Performance

Original comparison and reversed comparison, baseline e7bf89e8 and candidate eb24935d. Mixed 5k/10k/30k catalogs, ordinary table/view/index CREATE/DROP, 1/8 clients, two clean 20-second repetitions per cell. Profiled repetitions are excluded. Both arms of each pair use the same ARM64 node and 2-CPU/16-GiB limits, with matching configuration.

The reversed pair has 13/18 throughput improvements and five regressions, versus six improvements and 12 regressions originally. CREATE/DROP p95 regresses in 11/36 comparisons, versus 22/36 originally. Reversed-run throughput changes:

Object Clients 5k 10k 30k
table 1 -3.15% +0.72% +5.12%
table 8 -0.61% +1.50% -2.48%
view 1 -3.27% +5.90% +0.04%
view 8 +4.85% +0.65% +11.34%
index 1 -2.45% +4.60% +3.57%
index 8 +4.79% +0.40% +7.60%

The strongest repeated gains are 30k/c8 views (+11.22%, +11.34%) and indexes (+7.31%, +7.60%). Tables at 30k/c8 regress in both orders (-3.15%, -2.48%). The largest reversed-run p95 increase is 30k table/c8 CREATE, +12.14%. Seven original throughput regressions change direction. These observations support limited workload-specific benefits, not a general DDL speedup.

The reversed run additionally disables periodic configuration sync after verified initialization. Because the protocols differ, these pairs are not pooled as an order-only crossover. The remaining small-catalog regressions are not dismissed as noise.

Original workload profiles contain nested Database/Schema clone frames in 186/6,254 baseline weighted samples and 0/6,176 candidate samples. These are sample counts, not seconds. Unresolved frames and residual persistent-map work remain. Zero observed does not mean zero cost. CPU attribution bounds overlap in every reversed-run cell. CPU includes background work, and telemetry coverage is partial, including a missing candidate 30k/index/c1/repetition2 CPU/timer interval. No general memory or exact CRDB-call reduction is established.

Keep this PR draft. Broader performance claims require independent repetitions under one fixed protocol.

Release notes

None.

Use persistent ordered maps inside databases and schemas so mutating one
object does not clone every sibling namespace entry. Keep the SQL catalog
schema-ID interface independent of the map representation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant