Skip to content

Fix ORM over-hydration in measures, dimensions, git_sync APIs - #2434

Draft
shangyian wants to merge 2 commits into
mainfrom
perf/measures-dimensions-load-options
Draft

Fix ORM over-hydration in measures, dimensions, git_sync APIs#2434
shangyian wants to merge 2 commits into
mainfrom
perf/measures-dimensions-load-options

Conversation

@shangyian

Copy link
Copy Markdown
Collaborator

Summary

  • get_node_columns: replace per-column Node.get_by_name (full default load graph + per-column session.refresh) with a single batched Node.get_by_names call, matching columns in Python
  • get_measure_by_name: drop the full NodeRevision.default_load_options() chain on Column.node_revision and use load_only(NodeRevision.name) since that's all ColumnOutput reads
  • find_nodes_with_dimension: load only Node.id/Node.name instead of the full default load graph, since only those are used downstream
  • find_nodes_with_common_dimensions: batch the per-dimension get_node_by_name calls into one Node.get_by_names call with just load_only(Node.id, Node.name)
  • sync_node_to_git: switch from Node.cube_load_options() to the slimmer Node.export_load_options(), which already covers cube_elements and everything to_spec touches

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

- get_node_columns: replace per-column Node.get_by_name (full default
  load graph + per-column session.refresh) with a single batched
  Node.get_by_names call, matching columns in Python
- get_measure_by_name: drop the full NodeRevision.default_load_options()
  chain on Column.node_revision, load_only(NodeRevision.name) since
  that's all ColumnOutput reads
- find_nodes_with_dimension: load only Node.id/Node.name instead of the
  full default load graph, since only those are used downstream
- find_nodes_with_common_dimensions: batch the per-dimension
  get_node_by_name calls into one Node.get_by_names call with a slim
  load_only(Node.id, Node.name)
- sync_node_to_git: switch from Node.cube_load_options() to the slimmer
  Node.export_load_options(), which already covers cube_elements and
  everything to_spec touches
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit e16200c
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6a883a8bd29a1400086d08a6

The batched Node.get_by_names lookup dropped the per-column
session.refresh(col, ["node_revision"]) that used to backfill this
relationship, so MeasureOutput serialization (column.node_revision.name)
lazy-loaded outside the async context and 500'd on POST/PATCH /measures.
That's what collapsed measures.py coverage to 64% in CI -- most of the
file simply never ran. Restore eager loading via a nested joinedload
instead of the old N+1 refresh, and add a 404 test for the new
DJNodeNotFound raise in find_nodes_with_common_dimensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant