Initial import of LWLT AIBOT platform
This commit is contained in:
17
control-plane/migrations/010_task_query_optimization.sql
Normal file
17
control-plane/migrations/010_task_query_optimization.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Keep the operator list and active-task scans bounded by organization and
|
||||
-- lifecycle status. The list API still applies LIMIT/OFFSET, while these
|
||||
-- indexes avoid sorting/reading large unrelated task sets as data grows.
|
||||
CREATE INDEX IF NOT EXISTS tasks_visible_created_idx
|
||||
ON tasks (organization_id, created_at DESC, id DESC)
|
||||
WHERE status <> 'cancelled';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS tasks_active_status_created_idx
|
||||
ON tasks (organization_id, status, created_at DESC, id DESC)
|
||||
WHERE status IN ('queued', 'accepted', 'running', 'reconciliation_pending');
|
||||
|
||||
CREATE INDEX IF NOT EXISTS tasks_active_handoff_created_idx
|
||||
ON tasks (organization_id, handoff_status, created_at DESC, id DESC)
|
||||
WHERE handoff_status IN ('accepted', 'running', 'reconciliation_pending');
|
||||
|
||||
CREATE INDEX IF NOT EXISTS task_events_org_task_idx
|
||||
ON task_events (organization_id, task_id, id);
|
||||
Reference in New Issue
Block a user