4 ms·
"Queries that require multi-column indices will also be extremely inefficient of course, because they will require scans." If a query uses just the columns tha
by barrkel 12y ago
"Queries that require multi-column indices will also be extremely inefficient of course, because they will require scans."
If a query uses just the columns that are in a multi-column index, and doesn't sort in any order other than the index order, then the query may be much more efficient than a with a single-column index - since all the data may be retrieved from the index, rather than seeking to the row.
I think you left something out.
- jules 12y agoWe can decide which indices we have, you know. The conditions that you state are not by far the only conditions when a multi column index helps you. Even if you do not sort by the index order, and you do not have all the data in the index, the index may still be way more efficient. For example if you have SELECT A WHERE X=3 AND Y=5 ORDER BY B with an index (X,Y).