You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 592468b
Browse filesBrowse the repository at this point in the historyBrowse files
Load comments and users in chunks in wp comment list and wp user list (#666)
* Load comments and users in chunks in `wp comment list` and `wp user list`
Like `wp post list`, query the IDs of all matching comments or users
first, then load the objects a chunk at a time and clear the object
cache after each chunk. Combined with the formatter streaming CSV and
JSON output for iterators, the memory use no longer grows with the
number of items. If a displayed field is read through the object cache,
like user meta or the post title of a comment, the cache is kept.
Also only compute the `url` field of comments, users and terms when it
is displayed. For comments it took about 40% of the time.
The chunk size and the cache helper move to CommandWithDBObject.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
* Always clear the object cache after each chunk of comments and users
wp-cli/wp-cli#6426 makes the formatter read the requested fields of each
item while it is current, also when it can't stream them. User meta and
the post fields of comments are therefore read before the cache of their
chunk is cleared, so the cache no longer needs to be kept for them.
The posts of each chunk of comments are now loaded in one query, so that
fields like post_title don't load each post again in every chunk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
* Slice the IDs one chunk at a time when listing in chunks
array_chunk() builds all chunks up front, which holds a second copy of
every ID while the items are listed: about 25 MB per million IDs.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
* Separate the chunk slice from the aligned query arguments
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
* List a user only once when it matches the query more than once
The IDs query can return a user several times, e.g. when ordering by a
meta key the user has several values for. The second visit then failed,
as the user's roles had already been turned into a string. Listing by
objects, as before, returned each user once.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments