Database Indexes, Done Properly
Structures that let databases find rows quickly without scanning entire tables.
On this page
The key figures
- Lookups
- indexes speed up filtering and sorting
- Write cost
- every index must be updated on writes
- Composite indexes
- column order matters
- Query plans
- show whether an index is used
Why this is worth getting right
Missing indexes cause slow queries as data grows, while excess indexes slow writes and waste space.
Do this, not that
Do
- Index columns used in filters and joins
- Check query plans before and after
- Order composite index columns by selectivity
- Remove unused indexes
- Retest as data volume grows
Don’t
- Indexing every column
- Assuming an index is used
- Ignoring write performance
- Adding indexes without measurement
When to bring in help
Our advice Bring in help when queries slow down as tables grow.
Where this comes from
- Microsoft Learn — Database indexes
- Laravel Documentation — Database: Migrations
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.