performance icon indicating copy to clipboard operation
performance copied to clipboard

Module Proposal: Clean transient options (wp_options table)

Open merkys7 opened this issue 3 years ago • 9 comments

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

merkys7 avatar Jun 02 '22 14:06 merkys7

@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?

mxbclang avatar Jun 03 '22 17:06 mxbclang

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()

merkys7 avatar Jun 04 '22 12:06 merkys7

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

tillkruss avatar Jun 06 '22 16:06 tillkruss

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.

peterwilsoncc avatar Jun 08 '22 03:06 peterwilsoncc

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!

mxbclang avatar Jun 13 '22 12:06 mxbclang

Thank you @bethanylang I will begin working with it shortly

merkys7 avatar Jul 14 '22 15:07 merkys7

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 :)

JoelEadeDesign avatar Jul 23 '22 06:07 JoelEadeDesign

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.

johnbillion avatar Mar 13 '23 19:03 johnbillion

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.

Mte90 avatar Apr 02 '23 12:04 Mte90

So, expired transients are already automatically deleted by WordPress, and we already have #526 to optimize autoloaded options, so I don't think anything really needs to be done here.

swissspidy avatar Jan 27 '25 17:01 swissspidy