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?
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?
That depends on the query plan and what indexes you have on the table. Try putting EXPLAIN
before your query and MySQL will tell you more. Generally speaking though, if field1
is indexed, then LIKE
should only be performed for those rows where field1
is 42.