get_tasks_for_run() in services/ui_backend_service/data/db/tables/task.py (line 304) calls find_records() without passing a limit, so it defaults to 0 which means no LIMIT clause in the SQL. With enable_joins=True it fires the lateral joins against metadata_v3 and artifact_v3 for every task in the run.
The API layer is fine -- endpoints go through pagination_query() which caps at 1000. But this method gets called from the cache prefetch path in data/cache/store.py (line 221), which bypasses the API layer entirely.
For a run with a big foreach (hundreds of tasks), this is one unbounded query with lateral joins for each task row. Not sure how often the prefetch actually fires for large runs but it seems like it could be a problem at scale.
get_tasks_for_run()inservices/ui_backend_service/data/db/tables/task.py(line 304) callsfind_records()without passing alimit, so it defaults to 0 which means no LIMIT clause in the SQL. Withenable_joins=Trueit fires the lateral joins against metadata_v3 and artifact_v3 for every task in the run.The API layer is fine -- endpoints go through
pagination_query()which caps at 1000. But this method gets called from the cache prefetch path indata/cache/store.py(line 221), which bypasses the API layer entirely.For a run with a big foreach (hundreds of tasks), this is one unbounded query with lateral joins for each task row. Not sure how often the prefetch actually fires for large runs but it seems like it could be a problem at scale.