From bb52390c693f3f952d392b7e400873e2ac79a43e Mon Sep 17 00:00:00 2001 From: Adrien Foulon <6115458+Tofandel@users.noreply.github.com> Date: Tue, 25 Jan 2022 17:52:05 +0100 Subject: [PATCH] Improve query performance This query runs on every request and the first % is not needed thus it's a slow query because the index cannot be used in that case. This makes the query run about 20 times faster on a big table --- classes/transient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/transient.php b/classes/transient.php index 09d73d6fe..0f8beeb5d 100755 --- a/classes/transient.php +++ b/classes/transient.php @@ -162,7 +162,7 @@ public static function clear_wpcron(){ */ public static function get_all(){ global $wpdb; - $like = '%' . $wpdb->esc_like( 'cftransdata' ) . '%'; + $like = $wpdb->esc_like( 'cftransdata' ) . '%'; $query = $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s ", $like ); $return = []; $results = $wpdb->get_results($query,ARRAY_A);