Make WordPress Core

Opened 5 years ago

Last modified 4 years 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:


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

#1 @pento
5 years ago

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

#2 @examsdaily
5 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:

took around 8 seconds at times

#3 @philipjohn
4 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 which overrides the queries involved.

Note: See TracTickets for help on using tickets.