You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(collections): per-instance memo cache for getCollection
Every find/getDocument call hits Database::getCollection, which in
turn does getDocument(METADATA, id). With a no-op cache adapter
that's a SQL round trip per call — the dominant non-PDO cost on
read-heavy workloads.
Add a small per-Database memo of resolved collection metadata,
keyed by database/namespace/tenant/id so multi-tenant and
shared-table setups stay isolated. Cap at 256 entries with a hard
flush on overflow to keep long-lived workers bounded.
Hand callers a clone of the cached Document — createIndex,
updateAttribute, deleteIndex, etc. mutate the returned Document
in place during normal operation, so a shared reference would let
those mutations leak between calls and corrupt subsequent reads.
Invalidation is wired into purgeCachedCollection,
purgeCachedDocumentInternal (METADATA writes), and Database::delete
to keep the memo coherent with every existing schema-mutation path.
On the focus bench complex_query_nested drops a further 17%
(1794 ms vs 2150 ms) and order_cursor 6% (3661 ms vs 3900 ms)
relative to the previous round.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments