To get more out of your indexes, consider techniques like
covering indexes, which pack all the columns a query needs into the index (
CREATE INDEX idx_cover ON table(column1, column2)) so MySQL can skip fetching data from the table.
Then, there are
partial indexes that focus on just a subset of rows (
CREATE INDEX idx_active ON users(id) WHERE active = 1) – like those matching a specific condition – cutting the index size and boosting both query and write performance by ignoring irrelevant data.
And finally, combining multiple columns into a single index (
CREATE INDEX idx_multi ON table(column1, column2)), letting queries that filter on several fields run faster by narrowing results in one go instead of multiple passes.
Learn more about how to set this up in our guide to
creating a MySQL composite index.