MySQL Forums
Forum List  »  Performance

Re: To store or calculate on the spot?
Posted by: John Nahlen
Date: July 23, 2011 11:31AM

I may be wrong, but it sounds like the problem to me is: "To cache or not to cache".

Before I can give an answer (well, this is my answer), I must say it depends on the business requirements, how often "on the spot" is, AND how much data is in the table. What you want is some tradeoff between speed and 100% accuracy. If you have a boss for this job, ask him what he wants. If not, do whatever you think is best (but I imagine this forum will try to help you make that decision).

So, if storage is OK for your business rules, I would recommend that.
The other part was how often "on the spot is". If you must calculate on the spot every (FOR EXAMPLE.. again, it depends) maybe three minutes, I would recommend storing it instead of generating it live off of a possibly massive table (but I don't know how big your table is). So for slow operations, the fewer calls to the database the better. (Particularly with InnoDB and row-level locking... you're calling an aggregate function)

Don't forget that maybe you could do it nightly or weekly instead of just monthly, but that decision is entirely up to you and/or who you're doing this project for.

I'm speaking only from what I know, but I hope it helps. If I need to further explain anything or something, don't hold back on asking.

- John

Options: ReplyQuote


Subject
Views
Written By
Posted
3309
July 23, 2011 09:15AM
Re: To store or calculate on the spot?
1316
July 23, 2011 11:31AM
1090
August 10, 2011 07:22PM
1151
August 11, 2011 07:52PM
1006
August 12, 2011 07:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.