2 Votes Vote

How does MySQL handle WHERE tests?

Posted by topdog 523 days ago Questions| mysql tests mysql handle All

Hi,

As I was coding a php page building a MySQL request according to GET parameters, I was wondering if MySQL does any kind of reorganization of WHERE tests in a request, or if it just takes them as they come.

For example, if I execute this request:

SELECT * FROM `table` t WHERE (SELECT `some_value` FROM `another_table` u WHERE `t.id` = `u.id` LIMIT 1) = 10 AND `a_boolean` = 1;

Obviously the second test is faster and executing it first would filter a lot of entries, so there would be less subrequests to do for the other test. So, does MySQL reorganize the tests according to which one is faster/would filter the most entries, or does it just execute them in the given order?

Originally asked by: Jukurrpa on Stack Overflow

Discuss Bury


Who Voted for this Question