Skip to content

Commit

Permalink
HPOS - Made the query for retrieving meta keys more performant (wooco…
Browse files Browse the repository at this point in the history
…mmerce#46985)

* Modified query for fetching meta key, making it more perfomant

* added changelog

* Improved query when include_private is true

* Address review feedback

* Address review feedback
  • Loading branch information
naman03malhotra authored May 2, 2024
1 parent 6066c08 commit 1ba1e91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/fix-add-cache-46806
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: performance

HPOS - Made the query for retrieving meta keys more performant
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function get_meta_keys( $limit = 100, $order = 'ASC', $include_private =
$query = "SELECT DISTINCT meta_key FROM {$db_info['table']} ";

if ( ! $include_private ) {
$query .= $wpdb->prepare( 'WHERE meta_key != \'\' AND meta_key NOT LIKE %s ', $wpdb->esc_like( '_' ) . '%' );
$query .= $wpdb->prepare( "WHERE meta_key !='' AND meta_key NOT BETWEEN '_' AND '_z' AND meta_key NOT LIKE %s ", $wpdb->esc_like( '_' ) . '%' );
} else {
$query .= "WHERE meta_key != '' ";
}
Expand Down

0 comments on commit 1ba1e91

Please sign in to comment.