How would you go about selecting records timestamped within a certain amount of time of each other?
Application and sought solution:
I have a table with records of clicks, I am wanting to go through and find the clicks from the same IP that occurred within a certain time period.
e.g.: SELECT ALL ip_address WHERE 5 or more of the same ip_address, occurred/are grouped within/timestamped, within 10 minutes of each other
Decided not to try for a single query on the raw data.
After discussion with a friend, and then reading about options mentioning the memory engine, and PHP memcatche; I decided to go with a regular table to record click counts that use a time to live timestamp. After that timestamp is passed, a new ttl is assigned and the count is re-set.
One thing is for my application I can’t be exactly sure how long the parameter configuration settings will be – if they are larger and the memory gets cleared, then things start over.
It isn’t a perfect solution if it is run on user link click, but it should be pretty good about catching click fraud storms, and do the job.
Some managing PHP/MySQL code (“Drupalized queries”):
DB info: