[thelist] MySQL oddness
Raoul Snyman
raoul.snyman at saturnlaboratories.co.za
Wed Jan 30 03:22:01 CST 2008
Jeremy Weiss wrote:
> Quick question:
>
>> BTW, rule #1 of writing decent SQL: Never use SELECT *
>> This causes MySQL to first do a look up on all the columns of the table,
>> before then using them in the SELECT statement. When you specify the
>> columns, you firstly reduce the time it takes to execute the query and the
>> load on the MySQL server, and secondly you narrow the data down to only
>> that which you really need.
>
> Does this rule apply even if you do need every column in a table?
My answer would be "yes".
In the environment that I work in, fast queries are essential (I work
for one of the top online news sites in South Africa). So even if you
need every column in the table, a SELECT col1, col2, etc is faster than
a SELECT *.
While SELECT * is technically fine, I would say that it is not an SQL
best practice.
--
Raoul Snyman
Saturn Laboratories
e: raoul.snyman at saturnlaboratories.co.za
w: http://www.saturnlaboratories.co.za/
b: http://blog.saturnlaboratories.co.za/
http://raoulsnyman.co.za/
More information about the thelist
mailing list