Split chrPloidy into its own CTE in the CNV gene query - #230
Open
jbrestel wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GeneCopyNumbersByOrganism'sbySampleCTE (Model/lib/wdk/model/questions/queries/geneQueries.xml) joinedGeneCopyNumbersandChrCopyNumbersin one flat comma-join. This splits the chromosome side into its ownchrPloidyCTE and repeats the sample filter on both sides.Why
With the chromosome side pre-filtered, the planner parallelises the
GeneCopyNumbersscan — 2 workers,bySamplemeasured 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
eda_sample_stable_id,na_sequence_id) and the sameorganismrestriction on both tables, just expressed as an explicitJOINagainst a filtered CTE.ea4272bdc("Add na_sequence_id to the GeneCopyNumbers tuning index"), which is what makes the chromosome-side filter cheap.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 ANALYZEbefore merging if the CNV path matters for the release.🤖 Generated with Claude Code