Skip to content

fix(cloning): reduce redundant query graph allocations - #339

Merged
elpete merged 4 commits into
mainfrom
perf/avoid-derived-table-double-clones
Oct 15, 2026
Merged

elpete merged 4 commits into
mainfrom
perf/avoid-derived-table-double-clones

Conversation

@elpete

@elpete elpete commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Complex query graphs were repeatedly copied during refresh preparation, pagination counts, ordered UNION compilation, and derived-table attachment, creating substantial allocation pressure.

This change skips root filters and orders that the consuming operation discards, reuses privately owned count/aggregate snapshots, compiles SQL Server ordered UNION branches without cloning, and compiles eligible derived tables/joins directly while copying their bindings. CTE hoisting and explicit wrapping policies retain the existing clone path; retained mutable query inputs remain isolated.

Validation:

  • Full local qb suite: 3,416 passed, 10 skipped, zero failures/errors.
  • Full local Quick suite using this qb: 688 passed, 4 skipped, zero failures/errors.
  • Regression coverage checks SQL/bindings, nested caller mutation, compilation failure recovery, CTE hoisting, selective clone behavior, and retained graph isolation.
  • Allocation benchmarks on Lucee 5.4.8.3-RevSQLPatch / Java 11 showed 34–45% lower allocation for duplicate count/aggregate snapshots, 88–93% for ordered UNION compilation, and 66–74% for complex derived attachments. These are separate synthetic operation measurements, not production latency or retained-heap claims.

@elpete
elpete merged commit 61e5b13 into main Oct 15, 2026
51 of 52 checks passed
@elpete
elpete deleted the perf/avoid-derived-table-double-clones branch October 15, 2026 18:11
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