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

augustin (beginner) drupal.beginner at wechange.org
Fri Feb 13 05:08:25 UTC 2009


A while ago, someone (not me!) brought down our collocation server with a home 
made script which had many queries like this:


I.e. the script was indiscriminately selecting everything from the table even 
though he might have needed only a few fields.
This created heavy traffic between the SQL server and the web server which 
overwhelmed the platform. To be honest, I don't know the details (he might 
have been needlessly transferring whole images stored in the DB or something 
like this!)

In Drupal 6.9, I count 120 occurrences of SELECT * FROM ... , not including 
SELECT COUNT(*) but including variations of SELECT n.*, pi.* FROM ... .

Wouldn't it be a good idea to explicitly tell which fields are needed, in 
order to minimize traffic between SQL server and web server?

The SQL coding standards say nothing about this:

Should SELECT * FROM be considered a kind of bug?
Should this whole discussion be a 'won't fix' ? (why?)
Or is this something worth considering in the issue queue?



More information about the development mailing list