General developer forum

 
 
Tim at Lone Pine Koala Sanctuary
Re: Timestamps in mdl_user and mdl_log don't match
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

If you only use mdl_log for running reports, you will find that over time it gets very slow, because mdl_log gets very big. That is why the user_last_access table was added in the first place.

The other thing to note is that the lastaccess table is not updated every single time the user requests a page. There is a constant LASTACCESS_UPDATE_SECS (equal to 60 seconds) and to improve performance, the last access information is only updated that frequently.

 
Average of ratings: -
Picture of Chris Sequeira
Re: Timestamps in mdl_user and mdl_log don't match
 

Oh, that's why last_access always lags by less than a minute. First_access, however, varies wildly. I remember seeing forum posts about that - I'll look it up.

For reporting, I'm going to use separate summary tables created - and progressively updated (2 to 6 times a day) - from mdl_log and related tables. These summary tables would store aggregated data specifically for a set of predefined reports. No *.* rogue db queries allowed evil

So only the latest unsummarized records from mdl_log (and cousins) would be processed a few times a day. 

I'd done this a while ago in m1.9. The reports didn't have right-now info, but a "Report data as on <timestamp>" caption was fine with the big brothers. And, for those who couldn't wait, a couple of adhoc-query-powered Certified/Not Yet Certified-type reports maintained a reasonable level of contentment...

 
Average of ratings: -