Posted: Tue Jan 30, 2007 3:27 pm
I had the same problem when comparing directory/file names.
On a *nix platform you can have test.flac and Test.flac in the same directory.
So I first used this slow query:
It seems that for a BINARY compare the index doesn't work.
So when you first do a normal compare that uses an index and then use the BINARY compare it will speed up.
MySQL goes from left to right with logical operators (the same as PHP) so it narrows the search results for BINARY compare.
On my system it dramatically improved the speed.
Hope it will work out on your system to.
On a *nix platform you can have test.flac and Test.flac in the same directory.
So I first used this slow query:
Code: Select all
... WHERE BINARY relative_file = "' . mysql_real_escape_string($relative_file) . '"');So when you first do a normal compare that uses an index and then use the BINARY compare it will speed up.
MySQL goes from left to right with logical operators (the same as PHP) so it narrows the search results for BINARY compare.
Code: Select all
... WHERE relative_file = "' . mysql_real_escape_string($relative_file) . '"
AND BINARY relative_file = "' . mysql_real_escape_string($relative_file) . '"');Hope it will work out on your system to.