Skip to content

perf: add tasks_v3 index on (flow_id, run_number, step_name) for lateral joins - #500

Open
Shriprasad-P wants to merge 1 commit into
Netflix:masterfrom
Shriprasad-P:cursor/fix-tasks-v3-lateral-join-index-814e
Open

Shriprasad-P wants to merge 1 commit into
Netflix:masterfrom
Shriprasad-P:cursor/fix-tasks-v3-lateral-join-index-814e

Conversation

@Shriprasad-P

Copy link
Copy Markdown

Fixes

Fixes #475

Summary

Adds a concurrent composite index tasks_v3_idx_flow_run_number_step on (flow_id, run_number, step_name) so lateral joins from steps_v3 can use an index matching run_number (not only run_id).

Test plan

  • Migration follows existing goose patterns (IF NOT EXISTS, up/down)
  • Apply migration in a staging DB and confirm EXPLAIN uses the new index on join queries

Fixes Netflix#475

The steps_v3 table's lateral join queries tasks_v3 on (flow_id, run_number, step_name).
The existing composite index uses run_id (string) instead of run_number (integer),
preventing PostgreSQL from using the index for these joins.

This index supports joins in step queries with enable_joins=True, including step API
endpoints and heartbeat monitoring.
@Shriprasad-P
Shriprasad-P force-pushed the cursor/fix-tasks-v3-lateral-join-index-814e branch from b9cb750 to ceb85a1 Compare September 12, 2026 19:28
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.

tasks_v3 missing index on (flow_id, run_number, step_name) for lateral joins

1 participant