[wp-trac] [WordPress Trac] #27985: wp_enqueue_media() may be slow on very large sites

WordPress Trac noreply at wordpress.org
Wed Apr 23 05:23:47 UTC 2014


#27985: wp_enqueue_media() may be slow on very large sites
--------------------------+-----------------------------
 Reporter:  mboynes       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  3.9
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 I have sites with very large databases and I've noticed some slow queries
 since 3.9 on new/edit post screens:

 {{{
 SELECT post_mime_type, COUNT( * ) AS num_posts FROM wp_posts WHERE
 post_type = 'attachment' AND post_status != 'trash' GROUP BY
 post_mime_type
 }}}

 From my experience, this query can take upwards of a second to run on a
 large dataset. Given that it's not on every screen, and it's only really a
 problem on large databases, perhaps the benefits outweigh the costs. I
 figured it was best to open a ticket to ensure those costs are properly
 considered, as well as alternative solutions to get the same end result.

 This query is coming from `wp_count_attachments()` which is being called
 by `wp_enqueue_media()`. It looks like this was added in #27554.

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


More information about the wp-trac mailing list