Index lifecycle capacity checks instead of scanning retained jobs

This commit is contained in:
2026-10-06 12:54:10 -04:00
parent 37d380fa45
commit d2108eb604
6 changed files with 95 additions and 8 deletions
+2
View File
@@ -44,6 +44,8 @@ export function ensureHostSchema(handle: Database.Database): void {
-- causing a history scan for every queued command on Node's main thread.
CREATE INDEX IF NOT EXISTS ec_host_operations_kind ON ec_host_operations(host_id, kind, created_at);
CREATE INDEX IF NOT EXISTS ec_host_operations_kind_state ON ec_host_operations(kind, state);
CREATE INDEX IF NOT EXISTS ec_host_operations_active ON ec_host_operations(state, id)
WHERE state IN ('pending','accepted','running','unknown');
CREATE TABLE IF NOT EXISTS ec_host_operation_payloads (
operation_id TEXT PRIMARY KEY REFERENCES ec_host_operations(id) ON DELETE CASCADE,
payload TEXT NOT NULL