Make WordPress Core

Opened 6 years ago

Last modified 4 months ago

#45913 new defect (bug)

wp_enqueue_media() - slow query

Reported by: lubimow's profile lubimow Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0.3
Component: Media Keywords:
Focuses: performance Cc:

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 (4)

#1 @pento
6 years ago

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

#2 @examsdaily
6 years 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

#3 @philipjohn
5 years ago

This is quite an old problem that was originally addressed in #31071 but does appear to have returned. A work around for now is https://github.com/alleyinteractive/wp_enqueue_media_override which overrides the queries involved.

#4 @pbearne
4 months ago

can this be closed in favor of 31071?

Note: See TracTickets for help on using tickets.