I have a doubt that: Is (A and B)
vs (B and A)
is the same in terms of executing time in SQL?
Assuming I index (B, A) on my table and I query where A and B
, does SQL know to look up for B condition first and then A to take advantage of indexing?
If not, I have to query where B and A
, so it implied that A and B are different from B and A at SQL level?
Asked
Active
Viewed 106 times
1

Hieu Doan
- 115
- 1
- 7
-
"SQL" is a query language, not the name of a specific database product. Although i would say that no modern optimizer would treat them different, it's still important to know which DBMS product you are using, especially if it comes to index usage. – Feb 18 '20 at 06:57
-
@a_horse_with_no_name I use mysql, I also think it's the same but If so, does I query `where A and B` taking advantage of index(B, A) – Hieu Doan Feb 18 '20 at 09:20