WordPress.com REST API > Comment: audit and improve performance for comment counts #40587
Labels
[Feature] WPCOM API
[Focus] Performance
[Plugin] Jetpack
Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
[Pri] Normal
[Type] Task
-- p1732041372458899-slack-C01U2KGS2PQ
Reference:
jetpack/projects/plugins/jetpack/class.json-api.php
Lines 1113 to 1121 in 78d4035
Those direct queries were introduced in #10786 to allow us to include specific comment types in the counts.
Seems like the initial first step may be to add caching for
wp_count_comments
inWPCOM_JSON_API
, as @fgiannar had suggested in Slack at the time. Core'swp_count_comments
does come with caching, but in some scenarios we do direct queries in the WordPress.com API instead for the reasons mentioned above.Maybe it would also be worth looking at using
get_comments()
instead of doing a direct database query, since the underlyingWP_Comment_Query
does come with caching as well. This is what we do in other endpoints:jetpack/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-comments-endpoint.php
Line 333 in f4c805e
The text was updated successfully, but these errors were encountered: