Mysql Comparison of 'WHERE' methods
Is there a differenc开发者_如何学Pythone between these two where clauses in terms of speed? Are the column still indexed in the second one?
1. SELECT * FROM TableName WHERE col1 = 'a' AND col2 = 'b' AND col3='c'
2. SELECT * FROM TableName WHERE (col1,col2,col3) = ('a','b','c')
When
PRIMARY KEY (col1,col2,col3)
Thanks
There shouldn't be, but you can use EXPLAIN to find out in the context of your database.
Use EXPLAIN
to determine the execution plan for the queries.
If EXPLAIN
shows that they are the same, then the only time difference possible would be the parse time of the query string, which is insignificant compared to running the query.
Since you said EXPLAIN
shows the same, just pick whichever one you prefer, it won't matter which you pick.
You will get more information By using
EXPLAIN EXTENDED
精彩评论