> | But I have a question: is there any difference between the following? > | SELECT lname, fname FROM contacts WHERE lname = 'smith'; > | SELECT lname, fname FROM contacts WHERE lname LIKE 'smith'; > | Sincerely, > | -Josh > My > gut hunch is that if your LIKE expression is going to contain no wildcards, > you should probably write it as an '=' simply because it is likely to > perform better. > If anyone reading this is knowledgeable on MySQL performance, please jump in > and correct me if I'm wrong. > Rhino
There is nothing wrong... If you'll use '=' you will get in EXPLAIN SELECT a type of 'ref' and if you're using 'LIKE' you will get a type of 'range' witch is slower than 'ref'.. I have a table that stores id of a city, ccode is the country code for that city, and city... is a varchar containing the name of the town... there is an index '2din3' on 'ccode,city' let's see: Queries: EXPLAIN SELECT * FROM `com_cities` WHERE `ccode` LIKE 'EN'; EXPLAIN SELECT * FROM `com_cities` WHERE `ccode` = 'EN'; Results showing only differencies: type; ref range; NULL ref; const Of course things for me would make no big difference since `ccode` si a 2 letter CHAR... but for a varchar and a big table would ! Gabriel PREDA -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]