mrherman Posted September 5, 2010 Share Posted September 5, 2010 Hello, everyone: I'm using PHP and Mysql. I've got a table of that has 30 fields that I need to add together. I've got to do this for each record, and there are about 10,000 records. Which would be more efficient? SELECT SUM( field1 + field2...) or to make an array for the fields and then use array_sum() Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/212621-which-is-faster-mysql-sum-or-make-php-array-and-use-array_sum/ Share on other sites More sharing options...
Zane Posted September 5, 2010 Share Posted September 5, 2010 SUM() would be faster, unless you're adding other variables along with it... PHP variables. Quote Link to comment https://forums.phpfreaks.com/topic/212621-which-is-faster-mysql-sum-or-make-php-array-and-use-array_sum/#findComment-1107641 Share on other sites More sharing options...
mrherman Posted September 5, 2010 Author Share Posted September 5, 2010 Thank you!! Quote Link to comment https://forums.phpfreaks.com/topic/212621-which-is-faster-mysql-sum-or-make-php-array-and-use-array_sum/#findComment-1107644 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.