Can someone tell me what is the difference between the two:
ALTER TABLE x1 ADD INDEX(a); ALTER TABLE x1 ADD INDEX(b);
and
ALTER TABLE x1 ADD INDEX(a,b);
I know that it boils down to the very basics, but sometimes I find that the former seems a little faster than the latter. Is it just my feeling or is there some actual reason for this?
When using the second option, the following query will not use the index:
SELECT * FROM x1 WHERE b = 'something';
, . , . ( ) , .
: - :
INDEX "a" "b" . , "a" "a" AND "b" .
, "b" SQL.
- .
"a" "b" "b" , .
, , , . . , .
: , INDEX (a, b) INDEX (b, a), . , . .
, NAME SEX INDEX (NAME, SEX), , (es?).
INDEX(a,b)will speed up the search aor aand b, but not b, while the first ( INDEX(a)... INDEX(b)) will work in all cases.
INDEX(a,b)
a
b
INDEX(a)
INDEX(b)