If I run such a query in MySQL:
SELECT field FROM table WHERE field1=42 AND field2 LIKE '%beer%';
Will every row be parsed for having “beer” in field2 or only those whose field1=42?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That depends on the query plan and what indexes you have on the table. Try putting
EXPLAINbefore your query and MySQL will tell you more. Generally speaking though, iffield1is indexed, thenLIKEshould only be performed for those rows wherefield1is 42.