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 ?
pda4meAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Instead of the SELECT * how do I name individual column in the the query?  SELECT columna, columnb, columnc ?

Yes, exactly.  Performance will improve, too!

Best, ~Ray
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tigin44Commented:
Sure you may provide the name of the columns in the select list

Select col1, col2, col3, .... coln
from TableName
0
Cornelia YoderArtistCommented:
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.
0
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
the explaination is mainly in the amount of data that has to be kept in the buffers on the server side, then to be transported over the network, then stored in the buffers on the client side, and finally having an array/structure for 100 items while the application only needs 3-4 of them, but has to get through all the items eventually.

it's like you would buy an entire library, just to get 3-4 books you want to read.
0
pda4meAuthor Commented:
Thanks!
0
Ray PaseurCommented:
@angelIII: very well put! ~Ray
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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 ...
0
pda4meAuthor Commented:
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!
0
Ray PaseurCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.