[development] Is "SELECT * FROM ..." ok?

David Metzler metzlerd at metzlerd.com
Fri Feb 13 15:03:20 UTC 2009

Although there are merits in this argument, I wouldn't classify it as  
a bug.  There's a lot of generic/abstracted data loading, and as long  
as there's code at there that dynamically adds columns, select *  
actually is the sanest way to do things.

Also, the performance costs are database dependent. Mysql may work  
one way, but other db's work another.   Any DB with precompiled  
cached queries is not going to carry significant parsing overhead.   
The amount of data transfered in most cases is dependent on the size  
of the data in the column and not the number of columns.  So in some  
tables it may make sense.  You might get the name of the image file  
in drupal, but you're not likely to get the image.

Finally in my experience, most database performance problems lie in  
what is in the WHERE or JOIN, and not what's in the column list.


On Feb 13, 2009, at 4:37 AM, Morbus Iff wrote:

>> Should SELECT * FROM be considered a kind of bug?
> I personally consider it a bug, but I still haven't yet trained my  
> fingers to do it the proper way. I subscribe to the logic from:
>   http://www.parseerror.com/sql/select*isevil.html
> -- 
> Morbus Iff ( i'm the droid you're looking for )
> Technical: http://www.oreillynet.com/pub/au/779
> Enjoy: http://www.disobey.com/ and http://www.videounderbelly.com/
> aim: akaMorbus / skype: morbusiff / icq: 2927491 / jabber.org: morbus

More information about the development mailing list