Skip to content

Stop over-hydrating Node ORM entities in collections endpoints - #2439

Open
shangyian wants to merge 2 commits into
mainfrom
perf/collections-hydration
Open

Stop over-hydrating Node ORM entities in collections endpoints#2439
shangyian wants to merge 2 commits into
mainfrom
perf/collections-hydration

Conversation

@shangyian

Copy link
Copy Markdown
Collaborator

Summary

  • GET /collections/ keeps hydrating Collection.nodes even though CollectionInfo never returns nodes, so we can remove the selectin load of every node (and each node's created_by/tags) per collection.
  • GET /collections/{name} now loads only Node.name since that is all that's needed for the output.
  • POST /collections/{name}/nodes/ and /remove/ fetch only the node name and id, since this info is all that's needed to mutate the join table.

Test Plan

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

Deployment Plan

…n endpoints

- GET /collections/ noloads Collection.nodes since CollectionInfo never
  returns nodes, avoiding a selectin load of every node (and each node's
  created_by/tags) per collection.
- GET /collections/{name} loads only Node.name via selectinload+load_only
  and noloads created_by/tags, matching the name-only NodeNameOutput shape.
- POST /collections/{name}/nodes/ and /remove/ fetch nodes with
  load_only(id, name) and noload(created_by, tags) since the nodes are
  only used to mutate the join table, not returned in the 204 response.
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

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

@shangyian
shangyian marked this pull request as ready for review August 21, 2026 13:30
Going through collection.nodes loaded every node in the collection, and each
node's created_by and tags, to remove a few -- then session.refresh loaded them
all again for a 204 with no body. The read-modify-write it implies also races
with a concurrent edit on the same collection.

Deleting the join rows takes one statement and resolves the names in a subquery,
so no Node entities are loaded at all. Names matching nothing delete nothing,
which is what the membership check gave.

Also pass raise_if_not_exists: removing from a collection that does not exist
returned None and then raised AttributeError on collection.nodes, so a 500 where
the add path already returns 404.
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