WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 7 months ago

#45913 new defect (bug)

wp_enqueue_media() - slow query

Reported by: lubimow Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0.3
Component: Media Keywords:
Focuses: performance Cc:
PR Number:

Description

I have sites with very large databases and I've noticed some slow queries since 5.0.3 on new/edit post screens:

SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 
FROM wp_posts 
WHERE post_type = 'attachment' 
ORDER BY post_date DESC

This query is coming from wp_enqueue_media()

I am using php 7.2.1, MySQL 5.7.24

Change History (2)

#1 @pento
9 months ago

  • Component changed from General to Media
  • Focuses performance added
  • Version changed from trunk to 5.0.3

#2 @examsdaily
7 months ago

Yeah we too experience the issue, as the query call generates around 24000 rows in our case;
where we do host a blog with 10000 posts

caller info:
[do_action('admin_enqueue_scripts')
wp-includes/plugin.php:465
wp_enqueue_media()
wp-includes/media.php:3571]

took around 8 seconds at times

Note: See TracTickets for help on using tickets.