Filtering MySQL query result according to a interval of timestamp

Posted by celalo on Stack Overflow See other posts from Stack Overflow or by celalo
Published on 2010-06-07T02:05:56Z Indexed on 2010/06/07 2:12 UTC
Read the original article Hit count: 493

Filed under:
|
|

Let's say I have a very large MySQL table with a timestamp field. So I want to filter out some of the results not to have too many rows because I am going to print them.

Let's say the timestamps are increasing as the number of rows increase and they are like every one minute on average. (Does not necessarily to be exactly once every minute, ex: 2010-06-07 03:55:14, 2010-06-07 03:56:23, 2010-06-07 03:57:01, 2010-06-07 03:57:51, 2010-06-07 03:59:21 ...)

As I mentioned earlier I want to filter out some of the records, I do not have specific rule to do that, but I was thinking to filter out the rows according to the timestamp interval. After I achieve filtering I want to have a result set which has a certain amount of minutes between timestamps on average (ex: 2010-06-07 03:20:14, 2010-06-07 03:29:23, 2010-06-07 03:38:01, 2010-06-07 03:49:51, 2010-06-07 03:59:21 ...)

Last but not least, the operation should not take incredible amount of time, I need this functionality to be almost fast as a normal select operation.

Do you have any suggestions?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about Performance