[wp-trac] [WordPress Trac] #39878: meta_form inner query is very slow for big post_meta tables

WordPress Trac noreply at wordpress.org
Tue Feb 14 23:54:30 UTC 2017


#39878: meta_form inner query is very slow for big post_meta tables
--------------------------------+-----------------------------
 Reporter:  eddr                |      Owner:
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  4.7.2
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 1. This query on every edit page:
 {{{
 SELECT DISTINCT meta_key
 FROM wp_postmeta
 WHERE meta_key NOT BETWEEN '_'
 AND '_z'
 HAVING meta_key NOT LIKE '\\_%'
 ORDER BY meta_key
 LIMIT 30
 }}}
 is really expensive.

 2. My site has big post_meta table as I'm using lots of custom fields (via
 advanced custom fields plugin).

 3. Removing the filters from the query, in my case, results in the same
 result set exactly

 4. There should be some option for built-in transient/cache of some sort
 for this specific one. This doesn't change almost at all, so flushing the
 cache won't be a problem

 5. The "order by" part takes really a lot in terms of performance and I'm
 not sure it is needed really. maybe a filter to allow the developer to
 change it?

 Thanks

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39878>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list