WordPress.org

Plugin Directory

Delete Expired Transients

delete old, expired transients from WordPress wp_options table

Contributions

Useful SQL queries

Here's a few useful SQL queries to run in MySQL when you are trying to debug what's happening with transients.

-- transients that are not autoloaded (should be all with expiration times)
select option_name, option_value
from wp_options
where option_name regexp '^(_site)?_transient_.*'
and autoload='no'
order by option_name;
-- transient expirations
select option_name, option_value, from_unixtime(option_value) as expiry_time
from wp_options
where option_name regexp '^(_site)?_transient_timeout_.*'
order by option_value desc;
-- transient expirations with paired transients (inc. orphans)
select t1.option_name, t2.option_name, t1.option_value, from_unixtime(t1.option_value) as expiry_time
from wp_options t1
left join wp_options t2 on t2.option_name = replace(t1.option_name, '_timeout', '')
where t1.option_name regexp '^(_site)?_transient_timeout_.*'
order by t1.option_value desc;
-- expired transient expirations with paired transients (inc. orphans)
select t1.option_name, t2.option_name, t1.option_value, from_unixtime(t1.option_value) as expiry_time
from wp_options t1
left join wp_options t2 on t2.option_name = replace(t1.option_name, '_timeout', '')
where t1.option_name regexp '^(_site)?_transient_timeout_.*'
and t1.option_value < unix_timestamp()
order by t1.option_value desc;

Requires: 3.7 or higher
Compatible up to: 4.5.1
Last Updated: 1 month ago
Active Installs: 4,000+

Ratings

5 out of 5 stars

Support

0 of 1 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
100,1,1 100,1,1 100,1,1
100,1,1 100,2,2
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
100,2,2
100,1,1
100,2,2
100,2,2
100,1,1
100,2,2 0,1,0 100,2,2
100,1,1
100,3,3
100,1,1