[development] Guidelines for writing efficient SQL code

Pierre Rineau pierre.rineau at makina-corpus.com
Wed Aug 26 13:58:47 UTC 2009


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).

Pierre.

On Wed, 2009-08-26 at 09:18 -0400, Nancy Wichmann wrote:
> I am far from a MySql expert, as I am sure many on this list can attest to. But I have seen one thing that seems to make a big difference on some occasions and possibly somone can illuminate me on why. That is a numeric (say int(11)) index is used with "WHERE abc = 123" seems to be considerably slower than "WHERE abc = '123'", as explained by ANALYZE. Yet, we Drupallers mostly use the non-quoted version.
> 
> Nancy E. Wichmann, PMP
>  
> Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
> 



More information about the development mailing list