Mysql – Execution plan for select with empty value using wildcards


Short question: with this: foo like '%%', MySQL go through all records or through none?

If you are thinking why i need this, it's because i'm concatenating a search string and if this have no performance problem, i have to write less code.

Best Answer

Simple answer LIKE '%%' will always trigger an FULL index scan if the column is indexed.


if not indexed it will always trigger an FULL table scan.


Note an FULL index scan and FULL table scan is almost the same but an FULL index scan is more likely to be faster if the index size is smaller what is most likely the case..