Skip to content

Fix ORM over-hydration in namespace export + delete paths - #2435

Draft
shangyian wants to merge 2 commits into
mainfrom
perf/namespace-hydration
Draft

Fix ORM over-hydration in namespace export + delete paths#2435
shangyian wants to merge 2 commits into
mainfrom
perf/namespace-hydration

Conversation

@shangyian

Copy link
Copy Markdown
Collaborator

Summary

This reduces ORM over-hydration in three namespace-level paths:

  • GET /namespaces/{namespace}/export/ hydrated materializations, availability, and created_by for every node in the namespace via NodeRevision.default_load_options(), but the project-config builders only read what NodeRevision.export_load_options() already loads (this is the same trimmed down set that /export/spec uses).
  • DELETE /namespaces/{namespace}/ and POST /namespaces/{namespace}/restore/ built full NodeMinimumDetail / Node objects just to reduce them to node names, so we can switch both to just select the node name.
  • GET /datajunction-clients/python/notebook loaded the whole namespace (or whole upstream graph for cube export) with default node-output options. We can just use Node.export_load_options() instead since build_export_notebook only needs parents (topological sort), dimension_links, and columns/attributes. Per-node details are re-fetched individually by python_client_create_node anyway.

Test Plan

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

Deployment Plan

…ook paths

Three namespace-facing paths were pulling in ORM relationships their
consumers never touch:

- GET /namespaces/{namespace}/export/ hydrated materializations,
  availability, and created_by for every node in the namespace via
  NodeRevision.default_load_options(); the project-config builders only
  read what NodeRevision.export_load_options() already loads (same slim
  chain /export/spec uses).
- DELETE /namespaces/{namespace}/ and POST /namespaces/{namespace}/restore/
  built full NodeMinimumDetail/Node objects (joinedload current +
  selectinload tags) just to reduce them to node names; switched both to a
  plain select(Node.name) via a new get_node_names_in_namespace helper.
- GET /datajunction-clients/python/notebook loaded the whole namespace (or
  whole upstream graph for cube export) with default node-output options;
  passed Node.export_load_options() explicitly since build_export_notebook
  only needs parents (topological sort), dimension_links, and
  columns/attributes -- per-node details are re-fetched individually by
  python_client_create_node anyway.
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

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

Add a test covering NodeNamespace.list_nodes' include_deactivated
branch, which was only ever called with the default False value in
production code, leaving the True path (and its untested else-branch
skip) uncovered.

Also remove get_nodes_in_namespace from internal/namespaces.py: after
this branch's refactor to get_node_names_in_namespace, it had zero
remaining callers, leaving its only statement permanently uncovered.
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