WordPress.org

Make WordPress Core

Ticket #24498: 24498.patch

File 24498.patch, 594 bytes (added by swissspidy, 6 years ago)

Optimize the query

  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index 302e9b4..3ac7b5a 100644
    function meta_form( $post = null ) { 
    677677         * @param int $limit Number of custom fields to retrieve. Default 30.
    678678         */
    679679        $limit = apply_filters( 'postmeta_form_limit', 30 );
    680         $sql = "SELECT meta_key
     680        $sql = "SELECT DISTINCT meta_key
    681681                FROM $wpdb->postmeta
    682                 GROUP BY meta_key
     682                WHERE meta_key NOT BETWEEN '_' AND '_z'
    683683                HAVING meta_key NOT LIKE %s
    684684                ORDER BY meta_key
    685685                LIMIT %d";