[wp-trac] [WordPress Trac] #36904: Add caching to comment feed in WP_Query

WordPress Trac noreply at wordpress.org
Sun May 22 16:06:38 UTC 2016


#36904: Add caching to comment feed in WP_Query
------------------------------------------+-----------------------------
 Reporter:  spacedmonkey                  |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Query                         |     Version:  2.2
 Severity:  normal                        |  Resolution:
 Keywords:  needs-unit-tests needs-patch  |     Focuses:  performance
------------------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  has-patch needs-unit-tests => needs-unit-tests needs-patch
 * milestone:  Awaiting Review => Future Release


Comment:

 Thanks for the patch. A couple thoughts:

 * The 'comment' cache group is non-persistent. Adding caching as suggested
 in [attachment:36904.patch] won't do much, unless the same `WP_Query` is
 fired more than once on a given page load. See #36906.
 * Querying for comment IDs only, and then `array_map( 'get_comment',
 $comment_id )`, is going to result in a separate database query for each
 located comment (when the individual comment cache is not primed). We need
 something like `_prime_comment_caches()` here. It would reduce overhead if
 we could switch to `WP_Comment_Query` instead, though I haven't looked
 into how feasible this is.
 * Unless I'm mistaken, `$wpdb->get_results( "SELECT
 wp_comments.comment_ID..." )` will return an array of objects with a
 single property (`comment_ID`). I think you meant `get_col()`.
 * The two preceding points would be evident in the presence of test
 coverage :-D

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36904#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list