[wp-trac] [WordPress Trac] #56992: The Loop displays incorrect data for queries started with `fields => 'id=>parent'`.
WordPress Trac
noreply at wordpress.org
Fri Mar 14 00:04:39 UTC 2025
#56992: The Loop displays incorrect data for queries started with `fields =>
'id=>parent'`.
-------------------------------------------------+-------------------------
Reporter: peterwilsoncc | Owner:
| peterwilsoncc
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 6.8
Component: Query | Version: 3.1
Severity: normal | Resolution:
Keywords: dev-feedback has-patch has-unit- | Focuses:
tests | performance
-------------------------------------------------+-------------------------
Comment (by peterwilsoncc):
I've put together a PR to change how it's determined whether the method
needs to walk the array of posts for cache warming of posts and author
caches.
Over 1000 iterations of a large loop using various fields settings, the
performance regression for "all" is recovered.
Below are the average values for all versions of PHP used in the test
suite recorded using MariaDB 11.4. The number of queries is for each
iteration.
[https://gist.github.com/peterwilsoncc/a8a0934fe3749f69348052f4cf00ee2c
Data for each version of PHP can be found in this gist].
||= Fields =||= 6.7 Time =||= 6.7 Queries =||= Trunk Time =||=
Trunk Queries =||= Patch time =||= Patch Queries =||= Trunk - 6.7 =||=
Patch - 6.7 =||= Patch - trunk =||
|| all || 4.364121467 || 4 || 5.077857733 || 4
|| 4.390091121 || 4 || 0.7137362659 || 0.02596965432 ||
-0.6877666116 ||
|| ids || 5.359244257 || 5 || 5.227709651 || 5
|| 5.20280087 || 5 || -0.1315346062 || -0.1564433873 ||
-0.02490878105 ||
|| id, parent || 1.43522051 || 1 || 5.324584454 || 5
|| 5.331013381 || 5 || 3.889363945 || 3.895792872 ||
0.006428927183 ||
The performance hit for `id, parent` is only present if a developer starts
the loop. If they don't start the loop then it's performance shouldn't
change.
The [https://github.com/WordPress/wordpress-develop/pull/8495/files#diff-
1d050668621cbc3028e027d15e68438f4d879dd6e80ba98f9c9f69b9fb5469d0 source
code changes are in a PR]. The tesst suite changes won't go in as I've
hacked them to dump data, only run tests I needed and introduced a very
flakey test to get the timings.
----
The code in [comment:32 comment 32] is a good example of the improvements
this change makes, on a test install running the 6.7 code with twenty
twenty one it makes 19 extra database queries than the version of the code
in trunk.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56992#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list