Hey guys,

I manage a very large service that has dozens of MySQL read/writes coming in every second - one of our tables now has over 5+ million rows (and about 500MB of data), and the structure has three columns:

userid | data | timestamp

"userid" is a unique identifier for the user responsible for the data. Some users have thousands and thousands of entries -- others have only a few.

For those users with greater than 600 entries, I'd like to keep only their most recent 600 entries. Luckily we store a timestamp!

So, from a programming standpoint my thought was that I would have to loop through every single row, identify "duplicate" userids, put them into an array with their respective data and timestamps, and eventually purge those arrays down to 600 rows only, etc..

You can see that this would be pretty complicated, so I thought I would ask if any of you know of any good purging scripts / something that might help with this.

As advanced as this is, it can't be uncommon.

Thanks - let me know if you need any clarification!

David