Suchy Posted May 29, 2008 Share Posted May 29, 2008 I have a table with about 20 fields, and most of the time I only need info form 2 or 3 fields. But I always: SELECT * FROM ... Should I be using: SELECT id, name FROM ... ?? Is there a big differance in terms of performance of the website when not using the star ? Quote Link to comment https://forums.phpfreaks.com/topic/107736-use/ Share on other sites More sharing options...
peranha Posted May 29, 2008 Share Posted May 29, 2008 I have always been told to just select the data that you need, not all of it by using *. I have not seen a big different in using * though. Quote Link to comment https://forums.phpfreaks.com/topic/107736-use/#findComment-552298 Share on other sites More sharing options...
defeated Posted May 29, 2008 Share Posted May 29, 2008 I second what Peranha said. Apparantly it makes a difference when you get into thousands of rows. Always best to stick with best practice though just in case your db needs to get big all of a sudden. Quote Link to comment https://forums.phpfreaks.com/topic/107736-use/#findComment-552412 Share on other sites More sharing options...
PFMaBiSmAd Posted May 29, 2008 Share Posted May 29, 2008 Only selecting the data you need will result in the quickest operating application. Any data that you select that ends up in the result set must be physically retrieved from the database file, transfered from the mysql server to the php mysql client, and then stored in memory by the php mysql client. The time taken to retrieve, transfer, and store the data is directly proportional to the amount of data. Quote Link to comment https://forums.phpfreaks.com/topic/107736-use/#findComment-552462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.