WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#5820 closed enhancement (fixed)

Reduce queries by wp_count_posts()

Reported by: josephscott Owned by: ryan
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: General Keywords: has-patch
Focuses: Cc:

Description

The new function wp_count_posts() needs to do a query for each combination of post_type and post_status. By doing a 'GROUP BY post_status' for each post_type request we can provide more data with one query.

Here are patches that make this change and update the dashboard to make use of this new feature.

One other thing I came across in the dashboard is a query for the number of approved comments. The dashboard patch removes this query because that data isn't used anymore. If it does need to come back it should use the get_comment_count() function instead.

Attachments (2)

wp-includes-post.php.diff (1.1 KB) - added by josephscott 6 years ago.
wp-admin-index.php.diff (2.6 KB) - added by josephscott 6 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 ryan6 years ago

  • Owner changed from anonymous to ryan

comment:2 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6808]) Reduce queries by wp_count_posts(). Props josephscott. fixes #5820

Note: See TracTickets for help on using tickets.