performance - Mysql is slow in some cases while using 'LIKE' -
i have large table 60million entries.
lets call table have bigtable
, column tracking_code
(of type varchar(8)).
when use query
select * bigtable tracking_code 'sdmasgg_';
it takes 0.75 seconds execute whereas query
select * bigtable tracking_code 'sdma_ggh';
takes more 9 minuites.
i intrigued selectivity shown mysql towards location of '_'
my comment partially correct, though made mistake of thinking index wasn't used if wildcard anywhere other end of string in comparison.
mysql btree indexes can used in comparisons long
the argument constant string not start wildcard character
if have wildcard in middle of string, use characters beginning first wildcard. in second example, means query uses index match "sdma". after that, scan remaining rows find match.
Comments
Post a Comment