WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
344 stars 94 forks source link

Module Proposal: Clean transient options (wp_options table) #349

Open merkys7 opened 2 years ago

merkys7 commented 2 years ago

Feature Description

Expired Transients

Transients are the result of a form of caching that can happen in the WordPress database with the results of remote API calls. This option could clears all of the expired transients from the database.

Introduce a modal that would check and clean transient options

mxbclang commented 2 years ago

@merkys7 Thank you for this suggestion! Can you clarify that your intention here is that this would be a button or some other kind of option within the Performance Lab plugin settings?

merkys7 commented 2 years ago

I think we could display transient count / size in site-health checks using SQL query

SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time()

and a button to clean it using SQL query

DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time()
tillkruss commented 2 years ago

It'd be interesting to see the bytes as well.

peterwilsoncc commented 2 years ago

WordPress has an existing function for the query above, delete_expired_transients(), that ought to run daily on a scheduled task (ref).

Something in site health to delete expired, all, or auto-loaded transients would be lovely if they get large.

mxbclang commented 2 years ago

Thanks @merkys7! This would be a new plugin module, then. To move this forward, the next step would be to revamp this issue to become a proper module proposal. See the following documentation:

Once the details noted above are added to this issue, we can discuss this with the broader team in a future performance chat. Let me know if you have any questions. Thanks!

merkys7 commented 2 years ago

Thank you @bethanylang I will begin working with it shortly

JoelEadeDesign commented 2 years ago

Nothing to contribute other than I suspect this is the cause of a client's site with a 159GB options table. I can Optimize the table every few days but finding this thread eases my mind that I won't have to do it ongoing :)

johnbillion commented 1 year ago

Can we clarify what's being proposed here? As Pete mentioned, there's already a daily cron event which clears out expired transients.

What exactly is the problem looking to be solved?

I'm not sure I'm keen on adding a button to clear out all transients, or large transients, because a user needs to be able to make an informed decision about whether to click it, and it can cause cache stampedes on subsequent page requests as transient values are repopulated and re-cached.

Mte90 commented 1 year ago

Can we clarify what's being proposed here? As Pete mentioned, there's already a daily cron event which clears out expired transients.

What exactly is the problem looking to be solved?

I'm not sure I'm keen on adding a button to clear out all transients, or large transients, because a user needs to be able to make an informed decision about whether to click it, and it can cause cache stampedes on subsequent page requests as transient values are repopulated and re-cached.

I agree it isn't clear the focus of this ticket. Maybe can be more interesting to get the list of the most huge transients that are in autoload as example, usually it is something that I do when I am try to check the performances to see if some plugins is doing badly something.