|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Calculations faster in PHP or MySQL?
Hello,
We would like to have our web site automatically calculate pricing for customers. The price will be based on sizing, styles, materials and other options. Each option changes the value of other variables within the calculations. There will also be some global variables. While the calculations are confusing at times because of the variety of variables none of them are "complex". The only operands are +,-,* and /. No integrals, matrix theory and other fun stuff. So...my question is...would it be faster to do these calculations within the MySQL database or in a php format that then writes the answers to the MySQL database? One concern that we have is if a global variable changes at some later time we don't want old quotes already in the database to change. Does that mean we have to do it in PHP or is there a way around that in MySQL. This answer might just make the "which is faster" question a moot point. Thanks for any and all comments. Jim |
|
#2
|
||||
|
||||
|
I have found doing the calculations is about the same in both, However I have only made small sites with limited amount of viewers.
I will tell you doing the math in PHP is a little easier from the coding POV
__________________
CHornJr "One day I'll know what I am doing" ![]() My Blog Suanhacky Lodge #49 Rebel Squadrons |
|
#3
|
|||
|
|||
|
The answer is that it depends.
If you are using the results of two queries and then using maths on the two in PHP, then you will have the network roundtrip cost of both queries. However, MySQL implementation of maths in stored procedures is most likely going to be slower than PHP. The third factor is then scalability. It's often easier to add webservers than it is database servers if your application expands, so some quite large websites tend to keep the maths out of the database. - Morgan |
|
#4
|
|||
|
|||
|
Thank you both. So I guess it is PHP for the bulk of our calculations.
Thanks again! Jim |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Calculations faster in PHP or MySQL? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|