TEENFRONT Posted March 24, 2009 Share Posted March 24, 2009 Hey This maybe a stupid question, but everyone i look people seem to only SELECT * FROM ... even in tutorials... and therefore,thats what iv been doing for the last year... but our site is rather big and im thinking the little * is pulling waaay to much info than it needs, so i went through and converted * to specific columns that i need..its going to be a few days till i can see if this made an impact.. Server wise, will switching from * to specific columns needed make a difference? as id imagine with just selecting specific colums, it might take a little more processing to be specific, rather than * just pulls the whole lot..? Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/ Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 Quite contrary. Selecting only certain columns is actually faster. Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793050 Share on other sites More sharing options...
TEENFRONT Posted March 24, 2009 Author Share Posted March 24, 2009 thats what i was hoping for so selecting certain colums do i still do this to get the content? SELECT usernick, games_won, games_payed, tname FROM table while($row = mysql_fetch_array($result)){ $_SESSION['nickname'] = $row['usernick']; $_SESSION['played'] = $row['games_played']; $_SESSION['won'] = $row['games_won']; $_SESSION['tname'] = $row['tname']; } or would the columns already be in an array? also, if theres only one result set returned, im guessing i dont need the while statement? Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793059 Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 If there's only one result, while() is unnecessary.... you will save a microsecond or two You still need $row = mysql_fetch_array($result) and assigning variables to $_SESSION Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793067 Share on other sites More sharing options...
TEENFRONT Posted March 24, 2009 Author Share Posted March 24, 2009 every micro second helps when its been loaded hundreds of thousands of times lol. Thats great thanks very much! Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793074 Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 The most potential savings in time, when working with database, are in optimising queries and database design. For example creating an index where needed can give 10-fold or more decrease in query execution time. Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793078 Share on other sites More sharing options...
kickstart Posted March 24, 2009 Share Posted March 24, 2009 Hi As above. Also if you use SELECT * and the layout of the database changes then you can have unforseen effects (especially if you refer to column numbers rather than names). Also if you have a table join and a column is added to one table that has the same name as a column in the other table then again you can have unexpected abends in the future. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150952-select-or-select-this-this-this-this/#findComment-793133 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.