Reliably select from a database table at fixed time intervals
I have a fairly 'active' CDR table I want to select records from it every
say 5 minutes for those last 5 minutes. The problem is it has a SHA IDs
generated on a few of the other columns so all I have to lean on is a
timestamp field by which I filter by date to select the time window of
records I want.
The next problem is that obviously I cannot guarantee my script will run
on the second precisely every time, or that the wall clocks of the server
will be correct (which doesn't matter) and most importantly there almost
certainly will be more than one record per second say 3 rows '2013-08-08
14:57:05' and before the second expired one more might be inserted.
By the time for '2013-08-08 14:57:05' and get records BETWEEN '2013-08-08
14:57:05' AND '2013-08-08 15:02:05' there will be more records for
'2013-08-08 14:57:05' which I would have missed.
Essentially - imprecise wall clock time - no sequential IDs - multiple
records per second - query execution time - unreliable frequency of
running the query
Are all preventing me from getting a valid set of rows in a specified
rolling time window. Any suggestions for how I can go around these?
No comments:
Post a Comment