Just a simple question, but does the order of your index matter when it spans over multiple columns?
For example, taking the query:
SELECT * FROM my_table WHE
In the example you give, the column order does not matter.
It would matter if you order on a column; an index on (col1,col2)
can be used for ORDER BY col1, col2
but not for ORDER BY col2, col1
.
For WHERE
clauses, an index on (col1, col2)
works for WHERE col1 = 1 AND col2 = 1
. It also works for WHERE col1 = 1
. But it can't help with WHERE col2 = 1
.