Opened 4 weeks ago
Last modified 4 weeks ago
#58277 new enhancement
Change the position of notoptions lookup in get_option
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | performance | Cc: |
Description
Added in [4855] and #3726 the notoptions
cache was added to get_option
. This cache was designed to save database queries, do option name that are none not to exist in the database / cache.
However, the ordering this functions present a performance problem. In get_option
the look for if a option does not exist, is done before if it does. It is extremely uncommon for a get_option, for a option name that does not exist. Most times it is called, it for a option that does exist. This means the call to notoptions
cache is called pointless.
Moving this check, before the database lookup would improve performance.
Attachments (2)
Change History (6)
This ticket was mentioned in PR #4413 on WordPress/wordpress-develop by @spacedmonkey.
4 weeks ago
#1
- Keywords has-patch added
#2
@
4 weeks ago
- Keywords has-patch removed
500 runs on TT1
Trunk - TT1 | PR - TT1 | Trunk - TT1 - Memcached | PR - TT1 - Memcached | |
Response Time (median) | 73.16 | 73.1 | 73.62 | 72.49 |
wp-load-alloptions-query (median) | 0.7 | 0.69 | 0.68 | 0.68 |
wp-before-template (median) | 28.21 | 28.28 | 28.29 | 28.04 |
wp-before-template-db-queries (median) | 2.76 | 2.78 | 2.76 | 2.75 |
wp-template (median) | 37.73 | 37.64 | 38.11 | 37.62 |
wp-total (median) | 65.91 | 66.1 | 66.63 | 65.87 |
wp-template-db-queries (median) | 6.29 | 6.34 | 6.39 | 6.37 |
500 runs on TT3
Trunk - TT3 | PR - TT3 | Trunk - TT3 - Memcached | PR - TT3 - Memcached | |
Response Time (median) | 109.18 | 108.92 | 108.14 | 107.78 |
wp-before-template (median) | 58.54 | 58.76 | 55.08 | 54.61 |
wp-template (median) | 44.77 | 44.6 | 47.25 | 47.47 |
wp-total (median) | 103.52 | 103.45 | 102.76 | 102.47 |
#3
follow-up:
↓ 4
@
4 weeks ago
In a block theme, this saves 100s of calls to cache.
PR - 1302 vs Trunk - 1949.
#4
in reply to:
↑ 3
@
4 weeks ago
Replying to spacedmonkey:
In a block theme, this saves 100s of calls to cache.
Yep, this change makes sense imho. I'm a bit unsure on how to best test the result. Seems it would have to compare getting existing and non-existing options (that would trigger DB connections). Perhaps something like get an existing option 1000 times, and 5 different non-existing options 3 times each, etc.
In any case reducing the number of cache lookups is a good thing, even if the speed improvements are minimal.
Trac ticket: https://core.trac.wordpress.org/ticket/58277