I have a large table (millions of rows) where I need to find groups of records based on the presence of a certain column value and where a specified 'timeout' has not occurred. I figure one approach would be to find across the entire table where these 'timeout' gaps have occurred.
Example table:
+----------------+------+ | time | base | +----------------+------+ | 1245184797.064 | a | | 1245184802.020 | a | | 1245184807.103 | b | | 1245184812.089 | b | | 1245184816.831 | b | | 1245184821.856 | a | | 1245184821.856 | a | | 1245184855.903 | a | | 1245184855.903 | b | | 1245184858.362 | b | | 1245184858.362 | b | | 1245184860.360 | a | | 1245184860.360 | a | | 1245184862.174 | a | | 1245184862.174 | b | | 1245185001.480 | b | | 1245185417.556 | a | | 1245185417.844 | a | | 1245185419.960 | b | | 1245185420.181 | b | +----------------+------+
Given this set, how would I quickly find the points in the table where base=a hasn't occurred for a given number of seconds (say 5).
To boil it down, my objective is to find spans of records where base=a HAS occurred consistently without timing out.