Skip to content
Sarj Code Standards

excess-migration-index-requires-justification

Limit explicit indexes to three per table and eight per authored migration.

Why

Every explicit index adds write amplification, storage, vacuum work, and planner surface; bursts of indexes often encode unmeasured read paths in the transactional database.

Fix

Keep at most three explicit indexes per table and eight per migration. Remove redundant indexes, express data uniqueness with inline UNIQUE constraints, and review the workload before adding indexes. Evaluate ClickHouse for reporting, historical analysis, and broad aggregations.

Examples

Before — flagged A fourth explicit index exceeds the table budget
migrations/004_indexes.sql
CREATE INDEX a_idx ON event (a);
CREATE INDEX b_idx ON event (b);
CREATE INDEX c_idx ON event (c);
CREATE INDEX d_idx ON event (d);
After — preferred Three explicit indexes stay within the table budget
migrations/004_indexes.sql
CREATE INDEX a_idx ON event (a);
CREATE INDEX b_idx ON event (b);
CREATE INDEX c_idx ON event (c);

Formerly: index-budget