Basically I have a table that grows very fast as it registers all user impressions. However most of the data is useless, I only need the latest entry made for each user. (The table is used to authenticate users).
I’m looking to delete the old data, so the table should end up having a stable number of rows around the total number of registered users.
I can use a cron job, then there’s the option of simply adding a line at the end of the authentication script that deletes old rows. It would run on every page load.
DELETE WHERE `Date` < NOW() - SOME INTERVAL
Is this efficient, should I use a CRON JOB or what else?
Executing this from the page would add up to the time for the user login.
That is a bad approach. Better use cronjob or some other job scheduling tool like Jenkins