SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old February 13th, 2007, 03:27 PM
kestrel kestrel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 kestrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 54 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old February 13th, 2007, 06:40 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
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

Reply With Quote
  #3  
Old February 13th, 2007, 09:08 PM
morgo morgo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 1 morgo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 31 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old February 16th, 2007, 12:00 PM
kestrel kestrel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 kestrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 54 sec
Reputation Power: 0
Thank you both. So I guess it is PHP for the bulk of our calculations.

Thanks again!

Jim

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Calculations faster in PHP or MySQL?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway