Skip to content

Avoid N+1 querying MeasureDataPoints per dataset - #273

Open
bbliem wants to merge 1 commit into
mainfrom
fix/measure-datapoints-n-plus-one
Open

Avoid N+1 querying MeasureDataPoints per dataset#273
bbliem wants to merge 1 commit into
mainfrom
fix/measure-datapoints-n-plus-one

Conversation

@bbliem

@bbliem bbliem commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Each FrameworkMeasure(DVC) dataset loaded during a node computation queried the DB for its own measure datapoints, so an OutcomeNode with many such inputs fired the same query ~10 times per render.

Fetch all datapoints for the framework config once and cache them on the Context (Context.measure_datapoints), then slice in memory by UUID. All three call sites in frameworks/datasets.py now share this single query.

Fixes PATHS-BACKEND-5VK

Each FrameworkMeasure(DVC) dataset loaded during a node computation
queried the DB for its own measure datapoints, so an OutcomeNode with
many such inputs fired the same query ~10 times per render.

Fetch all datapoints for the framework config once and cache them on the
Context (Context.measure_datapoints), then slice in memory by UUID. All
three call sites in frameworks/datasets.py now share this single query.

Fixes PATHS-BACKEND-5VK
@kausal-code-coverage

kausal-code-coverage Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 23.80952% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
frameworks/datasets.py 18.75% 13 Missing ⚠️
nodes/context.py 40.00% 3 Missing ⚠️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #273   +/-   ##
=======================================
  Coverage   48.05%   48.06%           
=======================================
  Files         342      342           
  Lines       45386    45385    -1     
  Branches     6794     6795    +1     
=======================================
+ Hits        21809    21813    +4     
+ Misses      21895    21890    -5     
  Partials     1682     1682           
Flag Coverage Δ
e2e-tests 13.30% <0.00%> (+<0.01%) ⬆️
unittests 45.76% <23.80%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
nodes/context.py 63.38% <40.00%> (-0.24%) ⬇️
frameworks/datasets.py 14.05% <18.75%> (+0.89%) ⬆️

Impacted file tree graph

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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