Ticket #5820 (closed enhancement: fixed)

Opened 8 months ago

Last modified 8 months ago

Reduce queries by wp_count_posts()

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

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

wp-includes-post.php.diff (1.1 kB) - added by josephscott on 02/11/08 22:01:44.
wp-admin-index.php.diff (2.6 kB) - added by josephscott on 02/11/08 22:01:58.

Change History

02/11/08 22:01:44 changed by josephscott

  • attachment wp-includes-post.php.diff added.

02/11/08 22:01:58 changed by josephscott

  • attachment wp-admin-index.php.diff added.

02/11/08 22:35:24 changed by ryan

  • owner changed from anonymous to ryan.

02/13/08 09:30:26 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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