Does having a longer string in a SQL Like expression allow hinder or help query executing speed?
Posted
by Allain Lalonde
on Stack Overflow
See other posts from Stack Overflow
or by Allain Lalonde
Published on 2010-05-29T19:30:12Z
Indexed on
2010/05/29
19:32 UTC
Read the original article
Hit count: 202
mysql
|Performance
I have a db query that'll cause a full table scan using a like clause and came upon a question I was curious about...
Which of the following should run faster in Mysql or would they both run at the same speed? Benchmarking might answer it in my case, but I'd like to know the why of the answer. The column being filtered contains a couple thousand characters if that's important.
SELECT * FROM users WHERE data LIKE '%=12345%'
or
SELECT * FROM users WHERE data LIKE '%proileId=12345%'
I can come up for reasons why each of these might out perform the other, but I'm curious to know the logic.
© Stack Overflow or respective owner