Make WordPress Core

Opened 14 months ago

Closed 12 months ago

Last modified 9 months ago

#57801 closed enhancement (fixed)

Implement lazy loading comment meta in WP_Comment_Query

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.3 Priority: normal
Severity: normal Version: 4.5
Component: Comments Keywords: has-patch has-dev-note
Focuses: performance Cc:


When using WP_Comment_Query class, comment meta should be lazily loaded, as comment meta is not required for most page loads. Comment meta can easily be lazily load using existing apis found in core in the WP_Metadata_Lazyloader class.

Related to #57645 #57496

Attachments (2)

Screenshot 2023-02-24 at (10.2 KB) - added by spacedmonkey 14 months ago.
Screenshot 2023-02-24 at 14.07.12.png (11.0 KB) - added by spacedmonkey 14 months ago.

Download all attachments as: .zip

Change History (11)

This ticket was mentioned in PR #4128 on WordPress/wordpress-develop by @spacedmonkey.

14 months ago

  • Keywords has-patch added

#2 @spacedmonkey
12 months ago

  • Milestone changed from Future Release to 6.3

@spacedmonkey commented on PR #4128:

12 months ago

Awaiting review from @peterwilsoncc or @mukeshpanchal27

#4 @spacedmonkey
12 months ago

  • Keywords commit added
  • Owner set to spacedmonkey
  • Status changed from new to assigned

#5 @spacedmonkey
12 months ago

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

In 55749:

Comments: Always lazily load comment meta.

In [34270] introduced lazy loading of comment meta. However, this was only in the context of WP_Query. Other parts of the codebase, like WP_Comment_Query did not lazily load comment meta. In this change, calls to update_meta_cache are now replaced with wp_lazyload_comment_meta, that instead of priming comment meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where comment meta is being primed unnecessarily and never used. Adding everything to the comment meta queue, also means that if comment meta is used, that is all loaded in a single database / cache call.

Follow on from [55671], [55747].

Props spacedmonkey, peterwilsoncc, flixos90, mukesh27.
Fixes #57801.

#7 @spacedmonkey
12 months ago

@flixos90 @peterwilsoncc Create a ticket to deprecate wp_queue_comments_for_comment_meta_lazyload function #58301.

#8 @spacedmonkey
10 months ago

  • Keywords needs-dev-note added
Note: See TracTickets for help on using tickets.