[wp-trac] [WordPress Trac] #55463: Add a limit to _prime_*_cache functions
WordPress Trac
noreply at wordpress.org
Tue Apr 12 16:05:20 UTC 2022
#55463: Add a limit to _prime_*_cache functions
---------------------------------------------+---------------------------
Reporter: spacedmonkey | Owner: spacedmonkey
Type: enhancement | Status: assigned
Priority: normal | Milestone: 6.0
Component: Cache API | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-patch commit | Focuses: performance
---------------------------------------------+---------------------------
Comment (by spacedmonkey):
@peterwilsoncc Good call out.
I wrote a little test script. The site, has 250 pages. Using a get_posts
to get 20 pages. See attached screenshots.
The reasons are pretty clear cut.
The reason this is faster is because by adding a limit, it means when the
query runs and the criteria of the query and limit is met, the query can
finish. So if you are looking for 20 ids and limit by 20 when reach 20
rows, the query finishes. Without a limit, the database keeps scanning the
rows.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55463#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list