mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
perf: partial index so the startup NULL-active repair skips the table scan
Review finding: EXPLAIN QUERY PLAN showed the unconditional repair UPDATE doing SCAN messages (~75-135ms on 500k rows, every startup) — the existing idx_messages_session_active can't serve an active-only predicate. A partial index on (active) WHERE active IS NULL costs near-zero storage on healthy DBs (no NULL rows) and drops the 0-match repair to ~0.04ms. Lives in DEFERRED_INDEX_SQL because it references the reconciler-added column.
This commit is contained in:
parent
b75783e6dc
commit
11516f3cc3
1 changed files with 2 additions and 0 deletions
|
|
@ -802,6 +802,8 @@ CREATE INDEX IF NOT EXISTS idx_compression_locks_expires ON compression_locks(ex
|
|||
DEFERRED_INDEX_SQL = """
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_session_active
|
||||
ON messages(session_id, active, timestamp);
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_active_null
|
||||
ON messages(active) WHERE active IS NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_session_key
|
||||
ON sessions(session_key, started_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_gateway_peer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue