View Single Post
Old 09-29-2012, 06:16 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
If you select in a loop, then it will be very slow. Since you say by minute, that would indicate that you have queried 1440 times just to get the counts. That's way too many times, so many so that you may be crippling the SQL configuration for queries per hour if its set.

What do these returning records look like? You should be able to group by a minute() call, but I'm not sure how / if that is doable during a time range. If you use a range like logonDate and logoffDate, then you can use a mix of SQL and PHP easily for this (unless mysql has a specific method of doing this which I'm not sure of). That would be calculating a simple minute(logonDate) + (hour(logonDate) * 60) AS logonMinutes, minute(logoffDate) + (hour(logoffDate) * 60) AS logoffMinutes, and then given a list of all applicable entries between midnight and midnight PHP can loop each minute and check if the minute is between the logonMinutes and logoffMinutes. PHP could also make direct use of the datetime's themselves and use the DateTime and DateInterval methods to determine if it matches the between.

So the only question is what do the records look like?
Fou-Lu is offline   Reply With Quote