Black Friday - Cyber Monday Sale
30% OFF All Premium Licenses
  • 00 Days
  • 00 Hrs
  • 00 Mins
  • 00 Secs
Use code
SIGMA30

This 30% discount applies only to the first year. From the second year, renewals are charged at the regular price.

What are expired transients and how to clean them?

Younes JFR.

What are expired transients?

Transients are temporary pieces of data stored by WordPress, plugins, or themes to cache information and speed up performance. They are usually saved in the wp_options table, but in multisite installations, network-level transients are stored in the wp_sitemeta table instead. Each transient has an expiration time after which it should be automatically deleted. However, expired transients often remain in the database, taking up unnecessary space.

How they affect your database?

Expired transients stay in both the wp_options and wp_sitemeta tables after their expiration, even though they are no longer used. Over time, these outdated entries accumulate and can slow down database queries, especially when they are autoloaded. They also increase your backup size and can impact performance across all sites in a multisite network if not cleaned properly.

How to clean them?

1. Using Advanced Database Cleaner plugin

You can safely remove all expired transients using the General Cleanup module in Advanced Database Cleaner plugin.

This method is comprehensive, safe, and fully automated. It goes beyond standard cleanup methods by deeply scanning all areas where transients can exist, including:

  • Regular transients stored in the wp_options table.
  • Network-wide transients stored in the wp_sitemeta table on multisite installations.

Advanced Database Cleaner plugin intelligently detects and removes all expired transients, regardless of where they are stored, ensuring complete cleanup across your entire network. You can also schedule automatic cleanups to keep your database optimized at all times.

2. Using a raw SQL query

If you prefer to perform a manual cleanup, you can execute the following SQL command in phpMyAdmin for example:

DELETE FROM wp_options 
WHERE option_name LIKE '_transient_timeout_%' 
AND option_value < UNIX_TIMESTAMP();

And remember, for each subsite, replace wp_ with the correct prefix (for example, wp_2_, wp_3_, etc.).

Note:
While you can manually execute SQL commands to clean expired transients, Advanced Database Cleaner plugin provides a deeper, safer, and more reliable approach. It automatically locates and deletes expired transients from both wp_options and wp_sitemeta tables, fully supports multisite environments, and guarantees that your transient data is cleaned network-wide for maximum performance and stability.