Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#30928 closed enhancement (fixed)

Small performance improvement of wp_count_posts

Reported by: minderdl's profile minderdl Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.2 Priority: normal
Severity: normal Version: 2.5.1
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:


In wp_count_posts() the query is built all the time, even if the results from the cache are used (for which only the cache key is needed). Is there a reason for this?

IMO a small performance improvement can be made by moving the lines building $query inside the "if ( false === $counts )" branch.

Attachments (2)

30928.patch (1.5 KB) - added by SergeyBiryukov 9 years ago.
30928.diff (1.8 KB) - added by MikeHansenMe 9 years ago.

Download all attachments as: .zip

Change History (4)

9 years ago

#1 @SergeyBiryukov
9 years ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 4.2
  • Version changed from trunk to 2.5.1

Introduced in [7638].

#2 @SergeyBiryukov
9 years ago

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

In 31058:

Skip building the query in wp_count_posts() if cached results are used.

props MikeHansenMe.
fixes #30928.

Note: See TracTickets for help on using tickets.