oliver-zehentleitner / maity
hub: index chat_verdict.set_seq (redaction scans the table on PostgreSQL/SQLite); drop ix_placement_credential_id, covered by the new unique key
tsk-fscx0prcg7pj Open
Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: slow path / redundant index (migrations).
What is wrong
chat_verdict.set_seqhas no index:hub/src/maity_hub/migrations/versions/20261114200000_chat_verdict.py:46(column),:58-60(FK toevent.seq),hub/src/maity_hub/tables.py:2175; the only key is(message_seq, human_id)(tables.py:2177).chat_verdicts.redact_sentence(hub/src/maity_hub/chat_verdicts.py:99-104, called fromroutes/events.py:1108) runsUPDATE chat_verdict ... WHERE set_seq = :seqon every redaction of achat_verdictevent, so on PostgreSQL and SQLite it scans every verdict on the instance; the table only grows (kept with a deleted account). MariaDB indexes the FK by itself, so the three databases differ.20261117130000_plc_per_instance.py:32-34adds the unique key(credential_id, active)(tables.py:1490), which starts withcredential_id; the old single-columnix_placement_credential_id(tables.py:1470index=True, created in0008_placements.py:123) now only adds write cost. Lookups by credential (placements.py:712, 957, 1487, 1509) and MariaDB's FK are served by the unique key.
Proposal
- New migration on head: create
ix_chat_verdict_set_seq(plusIndex(...)intables.py); dropix_placement_credential_id(dropindex=Trueattables.py:1470), downgrade recreates it. Check the drop on the hub-mariadb run.
Effort / risk: S. Low risk; test_schema.py keeps model and migration in step.