Repository navigation
fix(tasks): list a table's tasks through the entity index - #2172
Conversation
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.
|
No actionable comments were generated in the recent review.
|
| 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:
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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
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.
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.
✅ PR Title Formatted CorrectlyThe title of this PR match the correct format. Thank you! |
Title:
fix(tasks): list a table's tasks through the entity indexListing 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 FROMinside anOR, 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 oftaskandtask_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):
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:
Release notes
Bug Fixes
🤖 Generated with Claude Code
Summary by CodeRabbit