MySQL Forums
Forum List  »  Performance

Re: To store or calculate on the spot?
Posted by: Rick James
Date: July 23, 2011 10:18PM

(MySQL has nothing automatic.)
The simple approach is for the nightly cron job to do
INSERT INTO SummaryTable
    SELECT datetime,b,c COUNT(*), SUM(xx), ... 
        FROM MainTable
        WHERE datetime >= CURRENT_DATE() - INTERVAL 1 DAY
          AND datetime < CURRENT_DATE()
        GROUP BY LEFT(10, datetime, 10),b,c;
(This assumes that you have a datetime field -- LEFT(...,10) is one way to turn that into just a date.

Options: ReplyQuote


Subject
Views
Written By
Posted
3309
July 23, 2011 09:15AM
Re: To store or calculate on the spot?
1173
July 23, 2011 10:18PM
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.