pda4me
asked on
PHP SQL Syntax with MySQL question
I have a table with close to 100 columns that I am currently doing a select * on.
Is it better to only select the columns I need?
Instead of the SELECT * how do I name individual column in the the query? SELECT columna, columnb, columnc ?
Is it better to only select the columns I need?
Instead of the SELECT * how do I name individual column in the the query? SELECT columna, columnb, columnc ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It is definitely more efficient to select only those columns you are going to use.
If you doubt, you can set up a quick benchmark recording the time before and after queries, and see how much better.
If you doubt, you can set up a quick benchmark recording the time before and after queries, and see how much better.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
@angelIII: very well put! ~Ray
>it's like you would buy an entire library, just to get 3-4 books you want to read.
additionally, developers doing this kind of code (select *) are then the ones complaining about network being slow and the like :/
glad to be of assistance ...
additionally, developers doing this kind of code (select *) are then the ones complaining about network being slow and the like :/
glad to be of assistance ...
ASKER
Yep, I just changed the select * to just the few columns I needed and its an AMAZING difference...this sure beats the cost of the upgraded server the sales rep was trying to "upgrade" us to...ha!
Bet you paid for your EE membership right there!
If you're looking for even more speed, you can try making those selection fields into indexes.
Warm regards, ~Ray
If you're looking for even more speed, you can try making those selection fields into indexes.
Warm regards, ~Ray
Select col1, col2, col3, .... coln
from TableName