[development] Guidelines for writing efficient SQL code

Earnie Boyd earnie at users.sourceforge.net
Wed Aug 26 21:12:57 UTC 2009

Quoting Nancy Wichmann <nan_wich at bellsouth.net>:

> Pierre Rineau wrote:
>> If you test a integer field, use no quotes, if you test a varchar field,
>> use quotes, that's it. Your DBMS will be smarter than you (except MySQL,
>> but for kitten sake, do standard SQL, it will be easier for PostgreSQL
>> user like me to port your code if needed).
> Then why, Pierre, is the quoted version faster, by far?  At least in MySql.
> Please stop disparaging MySql. The vast majority of sites use it, so it
> can't be all bad.

It makes no sense to me why a quoted numeric string is faster than a  
native integer unless the database engine is broken.  Not talking  
about MySQL vs anything else but integer comparison should be faster  
than string comparison.  My guess is that the database engine is  
converting the integer to string when storing it in the index file but  
I have no proof of that.  Have you tried your testing with InnoDB?

-- http://r-feed.com/           -- http://for-my-kids.com/
-- http://www.4offer.biz/       -- http://give-me-an-offer.com/

More information about the development mailing list