diff --git a/src/vahter-bot/migrations/V51__rawmessage_trgm_fastupdate_off.sql b/src/vahter-bot/migrations/V51__rawmessage_trgm_fastupdate_off.sql new file mode 100644 index 0000000..2b07767 --- /dev/null +++ b/src/vahter-bot/migrations/V51__rawmessage_trgm_fastupdate_off.sql @@ -0,0 +1,8 @@ +-- idx_forensic_*: debug-session indexes, not read by bot code. GIN ones are built with fastupdate +-- off, since a pending-list flush stalls the inserting webhook request for 10-30s on this tier. +DROP INDEX CONCURRENTLY IF EXISTS idx_event_rawmessage_trgm; +DROP INDEX CONCURRENTLY IF EXISTS idx_forensic_event_rawmessage_trgm; +CREATE INDEX CONCURRENTLY idx_forensic_event_rawmessage_trgm + ON event USING gin ((data->>'rawMessage') gin_trgm_ops) + WITH (fastupdate = off) + WHERE event_type = 'MessageReceived'; diff --git a/src/vahter-bot/migrations/V52__mark_forensic_indexes.sql b/src/vahter-bot/migrations/V52__mark_forensic_indexes.sql new file mode 100644 index 0000000..26249a7 --- /dev/null +++ b/src/vahter-bot/migrations/V52__mark_forensic_indexes.sql @@ -0,0 +1,8 @@ +-- Remaining debug-session indexes (V30, V38, V43, V48) get the idx_forensic_ prefix so the +-- catalog itself shows which indexes no bot query depends on. +ALTER INDEX IF EXISTS idx_event_username_lower RENAME TO idx_forensic_event_username_lower; +ALTER INDEX IF EXISTS idx_event_user_ban_by_stream RENAME TO idx_forensic_event_user_ban_by_stream; +ALTER INDEX IF EXISTS idx_event_mlscored_score_created_at RENAME TO idx_forensic_event_mlscored_score_created_at; +ALTER INDEX IF EXISTS idx_snapshot_user_username RENAME TO idx_forensic_snapshot_user_username; +ALTER INDEX IF EXISTS idx_snapshot_user_banned RENAME TO idx_forensic_snapshot_user_banned; +ALTER INDEX IF EXISTS idx_snapshot_user_spam_protection RENAME TO idx_forensic_snapshot_user_spam_protection;