Skip to content

Split chrPloidy into its own CTE in the CNV gene query - #230

Open
jbrestel wants to merge 1 commit into
masterfrom
perf/cnv-chrploidy-cte
Open

Split chrPloidy into its own CTE in the CNV gene query#230
jbrestel wants to merge 1 commit into
masterfrom
perf/cnv-chrploidy-cte

Conversation

@jbrestel

Copy link
Copy Markdown
Member

What

GeneCopyNumbersByOrganism's bySample CTE (Model/lib/wdk/model/questions/queries/geneQueries.xml) joined GeneCopyNumbers and ChrCopyNumbers in one flat comma-join. This splits the chromosome side into its own chrPloidy CTE and repeats the sample filter on both sides.

Why

With the chromosome side pre-filtered, the planner parallelises the GeneCopyNumbers scan — 2 workers, bySample measured at 4.3s instead of 7.2s single-threaded (~30%).

Repeating eda_sample_stable_id IN (...) on the gene side is what enables it: the gene side gets its own restriction rather than inheriting one through the join. The duplication is deliberate and is called out in a comment so it doesn't get "cleaned up" later.

Notes

  • Semantically equivalent — same join keys (eda_sample_stable_id, na_sequence_id) and the same organism restriction on both tables, just expressed as an explicit JOIN against a filtered CTE.
  • Builds on ea4272bdc ("Add na_sequence_id to the GeneCopyNumbers tuning index"), which is what makes the chromosome-side filter cheap.
  • Rebased onto current master (b4acd8369); clean, no conflicts.

Verification

Measurement above was taken when the change was written. The timings predate the rebase, and this has not been re-run against current master or built on an instance — worth a fresh EXPLAIN ANALYZE before merging if the CNV path matters for the release.

🤖 Generated with Claude Code

Pre-filtering the chromosome side and repeating the sample filter on the
gene side lets the planner parallelise the GeneCopyNumbers scan: bySample
drops from 7.2s single-threaded to 4.3s on 2 workers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jbrestel
jbrestel requested a review from kathryncrouch August 26, 2026 19:22
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