Index: src/wp-admin/includes/schema.php
===================================================================
--- src/wp-admin/includes/schema.php	(revision 25836)
+++ src/wp-admin/includes/schema.php	(working copy)
@@ -546,8 +546,24 @@
 
 	// delete obsolete magpie stuff
 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
-	// clear transient data
-	$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'" );
+
+	// Deletes all expired transients.
+	// The multi-table delete syntax is used to delete the transient record from table a,
+	// and the corresponding transient_timeout record from table b.
+	$time = time();
+	$wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
+	        a.option_name LIKE '\_transient\_%' AND
+	        a.option_name NOT LIKE '\_transient\_timeout\_%' AND
+	        b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
+	        AND b.option_value < $time");
+
+	if ( is_main_site() && is_main_network() ) {
+		$wpdb->query("DELETE a, b FROM $wpdb->options a, $wpdb->options b WHERE
+			a.option_name LIKE '\_site\_transient\_%' AND
+			a.option_name NOT LIKE '\_site\_transient\_timeout\_%' AND
+			b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
+			AND b.option_value < $time");
+    }
 }
 
 /**
Index: src/wp-admin/includes/upgrade.php
===================================================================
--- src/wp-admin/includes/upgrade.php	(revision 25836)
+++ src/wp-admin/includes/upgrade.php	(working copy)
@@ -1229,6 +1229,20 @@
  */
 function upgrade_network() {
 	global $wp_current_db_version, $wpdb;
+
+	// Always
+	if ( is_main_network() ) {
+		// Deletes all expired transients.
+		// The multi-table delete syntax is used to deletethe  transient record from table a,
+		// and the corresponding transient_timeout record from table b.
+		$time = time();
+		$wpdb->query("DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b WHERE
+			a.meta_key LIKE '\_site\_transient\_%' AND
+			a.meta_key NOT LIKE '\_site\_transient\_timeout\_%' AND
+			b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
+			AND b.meta_value < $time");
+	}
+
 	// 2.8
 	if ( $wp_current_db_version < 11549 ) {
 		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
