Repository navigation
Conversation
…nd_cres __make_cre_links was issuing a separate SELECT for each linked node — one query to fetch all Links rows for a CRE, then one more per row to fetch the corresponding Node. Replace with a single JOIN query so the whole thing resolves in one round-trip regardless of how many links a CRE has. __get_all_nodes_and_cres was fetching IDs first (SELECT id FROM …) and then re-querying each record individually. For CREs this chained into get_cre_by_db_id, which added a further SELECT external_id per CRE before finally calling get_CREs. Fetch full ORM objects directly and call get_CREs(external_id=) using the already-known external_id, cutting out that extra per-CRE round-trip. The same IDs-first pattern is fixed for the node branch.
|
Review: Concern: Blockers: CONFLICTING on main — needs rebase. Suggest author trim to |
|
For this too, I'll wait for GSoC PRs to get merged to avoid any conflicts and will incorporate the trim as suggested. Thanks! |
|
GSoC is over — we're going to land this ourselves rather than wait on another rebase cycle. Plan: keep the |
|
Correction after reading current
The remaining Proposal: close this PR as superseded. If we still want faster |
Graph load still called get_cre_by_db_id/get_nodes once per row. Reuse _hydrate_cres_batch and add a matching node batch so #850's JOIN goal actually lands.
Graph load still called get_cre_by_db_id/get_nodes once per row. Reuse _hydrate_cres_batch and add a matching node batch so #850's JOIN goal actually lands.
Fixes #848
What changed
__make_cre_linksReplaced the per-link
Nodefetch with a single JOIN query. Previously, for a CRE with L links this method issued 1 + L queries. It now issues one query regardless of link count.Before:
After:
__get_all_nodes_and_cresReplaced the IDs-first fetch pattern with direct ORM object queries. For CREs, the previous code called
get_cre_by_db_idper record, which added aSELECT external_id FROM cre WHERE id = ?round-trip before reachingget_CREs. Fetching full ORM objects and passing the already-knownexternal_iddirectly cuts that out. The same fix is applied to the node branch.Tests
All existing tests pass. The changed methods are exercised by
test_get_CREs,test_export,test_get_root_cres, andtest_get_cre_hierarchy.