Adding WHERE scopes which use an indexed column to a query that's primarily filtered by another column is a great way to speed up DB performance
- ·
- Telegram
- ·
- Newsletter
⚡️ Database Tip
Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition.