Indexes are the primary tool for accelerating query execution. Follow these best practices:
- Index columns used in
WHERE,JOIN,ORDER BY, andGROUP BYclauses. - Avoid over-indexing; each index adds write overhead.
- Use covering indexes to eliminate lookups.
- Periodically review and drop unused indexes.
| Scenario | Recommended Index Type |
|---|---|
| Range queries on dates | B-tree on date column |
| Full-text search | GIN/TSVector index |
| Unique constraints | Unique index |