[wp-trac] [WordPress Trac] #24498: Improving performance of meta_form()

WordPress Trac noreply at wordpress.org
Mon Feb 27 03:50:34 UTC 2023


#24498: Improving performance of meta_form()
----------------------------+--------------------------
 Reporter:  lumaraf         |       Owner:  pento
     Type:  enhancement     |      Status:  closed
 Priority:  normal          |   Milestone:  4.3
Component:  Administration  |     Version:  3.5
 Severity:  normal          |  Resolution:  fixed
 Keywords:  has-patch       |     Focuses:  performance
----------------------------+--------------------------

Comment (by neil_seddon):

 Hi,

 I'm following up to the slow wordpress dashboard.

 I've noticed this post titles Improving performance of meta_form() with
 ticket #24498

 I have been using the following code in the functions.php file.  However,
 the following code has to be removed as it removes the custom fields
 section.  Can anyone advise the best available code to add to the
 functions.php file to quicken the dashboard.

 add_action( 'admin_menu', 's9_remove_post_custom_fields_metabox');


 /**

  * Remove Ancient Custom Fields metabox from post editor

  * because it uses a very slow query meta_key sort query

  * so on sites with large postmeta tables it is super slow

  * and is rarely useful anymore on any site

  */

 functions9_remove_post_custom_fields_metabox() {

      foreach( get_post_types( '', 'names') as$post_type) {

          remove_meta_box( 'postcustom', $post_type, 'normal');

      }

 }

 add_action( 'admin_menu', 's9_remove_post_custom_fields_metabox');



 When I update any product I receive the following slow query under the
 Query Monitor.  The only way to quicken it is to use the full code further
 below but it removes the custom fields section.

 SELECT DISTINCT meta_key
 FROM orw_postmeta
 WHERE meta_key NOT BETWEEN '_'
 AND '_z'
 HAVING meta_key NOT LIKE '\\_%'
 ORDER BY meta_key
 LIMIT 30
 meta_form()
 WordPress Core  30      51.9917

 /**

  * Remove Ancient Custom Fields metabox from post editor

  * because it uses a very slow query meta_key sort query

  * so on sites with large postmeta tables it is super slow

  * and is rarely useful anymore on any site

  */

 functions9_remove_post_custom_fields_metabox() {

      foreach( get_post_types( '', 'names') as$post_type) {

          remove_meta_box( 'postcustom', $post_type, 'normal');

      }

 }

 add_action( 'admin_menu', 's9_remove_post_custom_fields_metabox');

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24498#comment:42>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list