HPOS - Made the query for retrieving meta keys more performant (#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
This commit is contained in:
Naman Malhotra 2024-05-02 20:54:10 +05:30 committed by GitHub
parent 6066c082b0
commit 1ba1e91a7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: performance
HPOS - Made the query for retrieving meta keys more performant

View File

@ -250,7 +250,7 @@ abstract class CustomMetaDataStore {
$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 != '' ";
}