ADR-0035: retain prepared Cypher in EF compiled delegates¶
Status: accepted. All 700 provider units, 241 live provider cases and 81 selected EF checks pass locally, zero failures/skips. FS-17's subsequent live comparison and scope audit (maintainer-local record) closes the increment with reproducible client preparation throughput, stable compiled reuse and broader execution evidence. No causal database-throughput improvement is claimed from noisy live timing observations.
The provider already uses EF's compiled query pipeline. Source inspection of EF 10.0.12 CompiledQueryCache, CompiledQueryCacheKeyGenerator and EntityFrameworkServicesBuilder confirms an existing memory-cache size policy and cache keys incorporating model, tracking behavior, async mode and expression shape. Replacing this cache or adding a second static command cache is unnecessary.
Previously Neo4jQueryingEnumerable rendered the plan on every execution and query-string inspection. Render the finalized plan in Neo4jShapedQueryCompilingExpressionVisitor and retain its immutable text in the compiled delegate. Include uses its existing renderer. Both ToQueryString() and async execution consume that text. Runtime parameter resolution, collection snapshots, validation, schema observations, fresh row buffers, tracking, cancellation and transaction ownership remain execution-specific.
No result rows, driver session, query context or parameter-value dictionary enter the prepared command. EF retains cache authority; eviction can recompile the same shape. The default cache uses abstract size units, not a guaranteed byte ceiling. Explicit compiled-query delegates are caller-owned and remain alive for as long as callers retain them; they are not governed by the ordinary automatic-query cache.
The offline experiment (maintainer-local record) retains exact binary hashes, matching command hashes and six process observations with unchanged profiling source. It establishes preparation overhead reduction only. Tests exercise changing parameters, cache eviction, bounded cache pressure and explicit async compiled execution. Full live regression covers streaming, Include, aggregates, cancellation and transactions. Two new live facts verify one compilation across fresh contexts and parameters, on-demand materialization of a 128-row result, independent entity values, cancellation and borrowed transaction preservation. Do not imply that preparation speedup proves server-side plan cache hits, database throughput or a memory bound for tracked results/complete Include collections.