Possible Duplicate:
Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc
What is the reason not to use select *?
Is there any performance issue in using SELECT * rather than SELECT FiledName, FiledName2 ... ?
Avoid using SELECT * There are many reasons for that recommendation, like: SELECT * Retrieves unnecessary data besides that it may increase the network traffic used for your queries. When you SELECT *, it is possible to retrieve two columns of the same name from two different tables (when using JOINS for example).
When you use select * you're make it impossible to profile, therefore you're not writing clear & straightforward code and you are going against the spirit of the quote. select * is an anti-pattern. So selecting columns is not a premature optimization.
Yes, the application needs to compare every record to the "distinct" records cache as it goes. You can improve performance by using an index, particularly on the numeric and date fields.
But BLOBS are stored separately and only reference is available with row data. Selecting distinct and less than all columns will always be faster than selecting *.
Take a look at this post:
What is the reason not to use select *?
and these:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With