Title: Problem transient
Last modified: April 26, 2021

---

# Problem transient

 *  Resolved [sylvsteph](https://wordpress.org/support/users/sylvsteph/)
 * (@sylvsteph)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-transient/)
 * I have a problem in my database in table wp_options. This morning I emptied the
   transient with wp-optimized. The table wp_options was 10 Mo. 9 hours later, the
   wp_options is 88 Mo. It’s full of hundreds of _transient_timeout_jetpack_restapi_stats_cache.
   More than 200 pages x 25 lines.
    The website is running since 2015 and I always
   used jetpack statistics. This is the first time my provider sends me an alert
   that there is a problem with the blog, so it’s the first time I look at the database.
 * Is there something automatic to delete these transient…?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [Jen H. (a11n)](https://wordpress.org/support/users/jennywp/)
 * (@jennywp)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-transient/#post-14376008)
 * Hi [@sylvsteph](https://wordpress.org/support/users/sylvsteph/),
 * Transients _should_ be periodically deleted from the database after they expire.
   If you want, however, [you can always use a plugin like this one](https://wordpress.org/plugins/wp-sweep/)
   to clear out the expired ones manually.
 *  Thread Starter [sylvsteph](https://wordpress.org/support/users/sylvsteph/)
 * (@sylvsteph)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-transient/#post-14376609)
 * Hi Jen,
    It seems they’re deleted only once a day after my database have double
   size. I use wp-optimize. Is it possible to clean them 4 or 5 times a day with
   a cron task (my host provider gives me a cron function in the workflow, I don’t
   know how to use it)?
 *  Plugin Contributor [Stef (a11n)](https://wordpress.org/support/users/erania-pinnera/)
 * (@erania-pinnera)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-transient/#post-14382806)
 * Hi [@sylvsteph](https://wordpress.org/support/users/sylvsteph/),
 * > Is it possible to clean them 4 or 5 times a day with a cron task (my host provider
   > gives me a cron function in the workflow, I don’t know how to use it)?
 * That sounds like a good option to try out. I’m not very much familiar with that
   cron function, so I’d suggest reaching out to your host again to know how to 
   use the script.
 * Alternatively, you can ask for more support from our community by opening a new
   thread here: [https://wordpress.org/support/forum/miscellaneous/](https://wordpress.org/support/forum/miscellaneous/)
 *  Thread Starter [sylvsteph](https://wordpress.org/support/users/sylvsteph/)
 * (@sylvsteph)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-transient/#post-14384645)
 * Hi Stef,
    Thanks for your answer. I see in Jetpack’s plugin, in Modules / Protect,
   a transient-cleanup.php file with:
 *     ```
       <?php
       /*
       Adapted from Purge Transients by Seebz
       https://github.com/Seebz/Snippets/tree/master/Wordpress/plugins/purge-transients
       */
       if ( ! function_exists( 'jp_purge_transients' ) ) {
   
       	/**
       	 * Jetpack Purge Transients.
       	 *
       	 * @access public
       	 * @param string $older_than (default: '1 hour') Older Than.
       	 * @return void
       	 */
       	function jp_purge_transients( $older_than = '1 hour' ) {
       		global $wpdb;
       		$older_than_time = strtotime( '-' . $older_than );
       		if ( $older_than_time > time() || $older_than_time < 1 ) {
       			return false;
       		}
       		$sql = $wpdb->prepare( "
       		SELECT REPLACE(option_name, '_transient_timeout_jpp_', '') AS transient_name
       		FROM {$wpdb->options}
       		WHERE option_name LIKE '\_transient\_timeout\_jpp\__%%'
       		AND option_value < %d
       		", $older_than_time );
       		$transients = $wpdb->get_col( $sql );
       		$options_names = array();
       		foreach ( $transients as $transient ) {
       			$options_names[] = '_transient_jpp_' . $transient;
       			$options_names[] = '_transient_timeout_jpp_' . $transient;
       		}
       		if ( $options_names ) {
       			$option_names_string = implode( ', ', array_fill( 0, count( $options_names ), '%s' ) );
       			$delete_sql = "DELETE FROM {$wpdb->options} WHERE option_name IN ($option_names_string)";
       			$delete_sql = call_user_func_array( array( $wpdb, 'prepare' ), array_merge( array( $delete_sql ), $options_names ) );
       			$result = $wpdb->query( $delete_sql );
       			if ( ! $result ) {
       				return false;
       			}
       		}
       		return;
       	}
       }
   
       /**
        * Jetpack Purge Transients Activation.
        *
        * @access public
        * @return void
        */
       function jp_purge_transients_activation() {
       	if ( ! wp_next_scheduled( 'jp_purge_transients_cron' ) ) {
       		wp_schedule_event( time(), 'daily', 'jp_purge_transients_cron' );
       	}
       }
       add_action( 'admin_init', 'jp_purge_transients_activation' );
       add_action( 'jp_purge_transients_cron', 'jp_purge_transients' );
       ```
   
 * I’m not sure it works because I see hundreds of _transient_timeout_jpp_ in the
   database. And thousands of stats transients (200 pages in the wp_options db).
   
   Maybe the transient_cleanup.php file would need a more efficient cleaning?
 *  [Bruce (a11n)](https://wordpress.org/support/users/bruceallen/)
 * (@bruceallen)
 * Happiness Engineer
 * [5 years ago](https://wordpress.org/support/topic/problem-transient/#post-14398847)
 * Hi [@sylvsteph](https://wordpress.org/support/users/sylvsteph/)
 * Another plugin you could try is the [Transients Manager](https://wordpress.org/plugins/transients-manager/).
 * It should allow you to see if transients are correctly being deleted on your 
   site, or if they remain after their expiration, which could narrow down what’s
   happening here.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem transient’ is closed to new replies.

 * ![](https://ps.w.org/jetpack/assets/icon.svg?rev=2819237)
 * [Jetpack - WP Security, Backup, Speed, & Growth](https://wordpress.org/plugins/jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [Bruce (a11n)](https://wordpress.org/support/users/bruceallen/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/problem-transient/#post-14398847)
 * Status: resolved