Open rubengc opened 5 years ago
This approach could work in cases with smaller sets of logs for sure.
My major concern with this is that it doesn't have a limit. Even though this has it's own cron, it is still going to attempt to delete ALL rows from the DB, and on the first run it's likely to cause a massive spike in the MySQL CPU and Memory usage as it runs the query and then has to reindex all the tables touched. It'd be best if it has a limit attached to it and over time, your logs prune. Maybe adding an order by post_date ASC and limit to 200 (or something that makes sense for shared hosting environments) would help with not overrunning a cron and having it hit the PHP timeout, essentially leaving us in a state where all 3 of these didn't' complete correctly.
Hi @cklosowski
It's true that I was design this daily clean up after perform some manual clean up
For that it will just facing daily API requests (around 5.000)
A posible improvement could be, as you mention, limit the query and running it hourly I have around 5.000 API requests logs daily so a limit of 200 won't help so much
Hi EDD team
I was facing issues with an excessive database size caused by the amount of posts and post metas generated by the EDD rest API
For that, I was in the need to create a functionality that cleans up all API requests logs and I want to share it to the EDD development team
The code is safe to run included if you make (finally) the migration of logs on another table since will query directly to database matching posts by post_type
There is the code:
Hope it helps