Narrow eager-load options on hot SQL/data read paths - #2441
Draft
shangyian wants to merge 1 commit into
Draft
Conversation
Node.get_by_name/get_by_names default to a large eager-load graph, and mapper-level lazy="selectin" on Node.created_by/tags fires even when options=[] is passed. Narrow the loader chains on the four hottest call sites to only what's actually consumed: - internal/sql.py build_node_sql: load only current.catalog.engines instead of the full default chain. - api/data.py get_data / get_data_stream_for_node: same narrow catalog+engines chain, used only by resolve_engine and node.current.catalog.name. - api/sql.py get_sql_for_metrics: switch to a column select (Node.name, Node.type) instead of materializing Node entities, avoiding the mapper-level created_by/tags selectin fan-out. - api/metrics.py get_common_dimensions: load_only the columns actually read (id, name, type, current_version) and noload created_by/tags.
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/sql.py'sbuild_node_sql: load only the current revision's catalog + engines instead of the full default chain.api/data.py'sget_data/get_data_stream_for_node: similar to the above, load only the catalog + engines, which are used to choose the right engine.api/sql.py'sget_sql_for_metrics: switch to a column select instead of hydrating the fullNodeORM obj.api/metrics.py'sget_common_dimensions: load only the columns actually read and avoid fanout tocreated_by/tags.Test Plan
make checkpassesmake testshows 100% unit test coverageDeployment Plan