The leftmost prefix rule, and why it decides everything
Then order by what the query does next
- Equality predicates
- One range predicate
- Columns used for ORDER BY
Sql
Reading the plan
Sql
- type: ref or range — using the index. Good.
- type: ALL — full table scan.
- Extra: Using index — covering index, never touched the table. Best case.
- Extra: Using filesort — sorting in memory or on disk because the index did not provide order.
- Extra: Using temporary — materialising a temp table, usually with GROUP BY.
Php
Covering indexes for hot list endpoints
Sql
Redundant indexes are silent tax
Sql
The uniqueness one people miss
Php
Related articles
- Laravel Multi-Tenant Scoping: Queries Global Scopes Miss
- Roles vs Permissions in Multi-Company Laravel SaaS
- ROI LevelUp: Laravel Multi-Company SaaS Case Study
Need a backend built right? Hire me for remote Laravel roles.