Skip to content

fix(tasks): list a table's tasks through the entity index - #2172

Merged
c-thiel merged 1 commit into
mainfrom
ct/list-table-tasks-performance
Oct 24, 2026
Merged

c-thiel merged 1 commit into
mainfrom
ct/list-table-tasks-performance

Conversation

@c-thiel

@c-thiel c-thiel commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Title: fix(tasks): list a table's tasks through the entity index

Listing tasks filtered by a table, view or generic table no longer reads all tasks of the warehouse. The filter matched entities with IS NOT DISTINCT FROM inside an OR, which no index serves, so a lookup for a table with few or no tasks took seconds in a warehouse with a long task history. Each entity is now read through the existing per-entity indexes of task and task_log, newest first, up to the page size. Pages after the first now start the index scan at the page token. Results are unchanged. No migration.

Measured on Postgres 16, 17 and 18: one warehouse with 1.69 M finished tasks and 51,000 active tasks across 1,000 tables. Execution time in ms (16 / 17 / 18):

Listing Before After
table with no tasks, page 1 2,163 / 2,100 / 2,201 0.6 / 0.4 / 0.4
table with 13 tasks, page 1 1,966 / 2,035 / 2,229 0.4 / 0.5 / 0.6
table with 5 tasks, successes only, page 5 1,947 / 2,075 / 2,275 0.4 / 0.4 / 0.4
table with 25,920 tasks, page 1 1.4 / 1.7 / 1.5 0.3 / 0.2 / 0.2
filtered by warehouse, page 100 52 / 59 / 50 6.2 / 6.3 / 5.7
unfiltered, page 100 1.3 / 1.7 / 1.1 2.3 / 1.2 / 1.4
unfiltered, a page from the middle of the history 1,680 / 1,717 / 1,723 0.6 / 0.4 / 0.4

Planning takes about 1 ms per call, up from about 0.5 ms. The rows returned are identical to before for 23 parameter sets (41 pages) on all three versions.

Not changed by this PR:

  • A listing filtered by warehouse together with a queue that has no warehouse tasks still reads all tasks of the warehouse.
  • A table filter combined with a queue the table rarely runs reads all of that table's tasks: tens of milliseconds for a table with 26,000 tasks.

Release notes

Bug Fixes

  • Listing the tasks of one table is fast in warehouses with many tasks. The task list filtered by a table, view or generic table read all tasks of the warehouse. It now reads only the newest tasks of that table, view or generic table. Later pages of the task list are also fast.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved task lists when filtering by entity or warehouse, including warehouse schedule tasks.
    • Pagination now returns tasks in the expected order and more reliably continues from the selected page.
    • Completed task entries show the latest attempt, while active retries remain visible alongside failed task records.

Listing tasks filtered by a table, view or generic table no longer reads all tasks of the warehouse. The filter matched entities with `IS NOT DISTINCT FROM` inside an `OR`, which no index serves, so a lookup for a table with few or no tasks took seconds in a warehouse with a long task history.

Each entity is now read through the per-entity indexes of `task` and `task_log`, newest first, up to the page size. The unfiltered listing and the listing filtered by warehouse each run in their own branch. The unfiltered branch is switched on at run time, so that Postgres 16 does not count the skipped branch as a full scan. Later pages start the index scan at the page token. Results are unchanged. No migration.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1665cff6-aabf-4793-84ff-7cff0dda29ef
Commits

Reviewing files that changed from the base of the PR and between e862934 and 1fd8006.

Files ignored due to path filters: 2
  • .sqlx/query-35c4706a221e6e0ff28b27d1eafef266f63174f1e247ac2db198724b64a3c4cb.json is excluded by !.sqlx/**
  • .sqlx/query-a9a6371edc359aa49ffa0f40a895818215de04187f1f0e6cafe6729ae125641e.json is excluded by !.sqlx/**
Files selected for processing: 1
  • crates/lakekeeper-storage-postgres/src/tasks/list_tasks.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The task listing query now builds separate branches for unfiltered, entity-filtered, and warehouse-filtered active and logged tasks. It adds pagination bounds and deduplicates entity filters. New tests cover filter matching, pagination order, and task attempts.

Changes

Task listing

Layer / File(s) Summary
Entity filters and query branches
crates/lakekeeper-storage-postgres/src/tasks/list_tasks.rs
Entity filters are deduplicated before query execution. Active and logged tasks use separate unfiltered, per-entity, and warehouse branches. Each branch applies its own limit, and the query includes a page-token upper bound.
Filter, pagination, and attempt coverage
crates/lakekeeper-storage-postgres/src/tasks/list_tasks.rs
Test helpers and cases cover table and warehouse filters, warehouse schedule tasks, descending pagination across task groups, and logged attempts alongside active retries.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to 1fd80

No actionable issue is established from the supplied evidence; merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: task listings for a table now use the entity index.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the task list rows,
Where table-filtered data flows.
Warehouse tasks join the queue,
Page tokens guide the order through.
Retries and logs appear in view,
The rabbit hops, its checks all true.

Comment @coderabbitai help to get the list of available commands.

@c-thiel
c-thiel enabled auto-merge (squash) October 24, 2026 12:51
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit 6025649 into main Oct 24, 2026
104 of 122 checks passed
@c-thiel
c-thiel deleted the ct/list-table-tasks-performance branch October 24, 2026 17: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.

1 participant