Skip to:

Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#3163 closed enhancement (fixed)

Prime last active post IDs

Reported by: johnjamesjacoby Owned by:
Milestone: 2.6 Priority: high
Severity: normal Version: 2.0
Component: General - Performance Keywords: commit


I've identified a nifty (and relatively obvious) performance improvement.

When querying for forums, topics, or replies, the last-active post caches are never primed. This makes WordPress go out and query for each of them individually, maybe miss the cache, and do all of the work again for each individual cache miss.

Instead of all that, let's ask each already-cached post object what their last-active, last-topic, and last-reply IDs are, and prime them.

In my testing, this can result in embarrassingly huge performance improvements, sometimes cutting the number of database queries by 50% or more depending on the intersection of post types, widgets, etc...

Change History (5)

#1 @johnjamesjacoby
4 years ago

In 6698:

Common: prime last-active post caches.

This change introduces a performance tweak to bbp_has_topics(), bbp_has_forums(), and bbp_has_search(), pre-cache'ing the last-active post objects for what is known to be their imminent usage in the current template loops.

See #3163.

#2 @johnjamesjacoby
4 years ago

In 6700:

Common: also prime post author caches.

This change introduces another performance tweak to bbp_has_topics(), bbp_has_forums(), bbp_has_search(), and bbp_has_replies(), by pre-cache'ing the post author objects for what is known to be their imminent usage in the current template loops.

This change also renames the function & parameter introduced in r6698 to better fit existing naming conventions in WordPress.

See #3163.

#3 @johnjamesjacoby
4 years ago

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

Let's call this closed.

On a heavily trafficked forum with high cardinality and low intersection, I've seen forum index queries go from 120 to 46. We can deal with anything related to this in separate issues.


#4 @johnjamesjacoby
4 years ago

In 6701:

Update docblock for bbp_update_post_family_caches(). See #3163.

#5 @johnjamesjacoby
2 years ago

Assigning all closed & unassigned tickets in the 2.6 milestone to myself.

Note: See TracTickets for help on using tickets.