[wp-trac] [WordPress Trac] #58277: Change the position of notoptions lookup in get_option

WordPress Trac noreply at wordpress.org
Fri Sep 15 16:14:10 UTC 2023


#58277: Change the position of notoptions lookup in get_option
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
                                                 |  spacedmonkey
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  6.4
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch needs-unit-tests needs-    |     Focuses:
  refresh                                        |  performance
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56595" 56595]:
 {{{
 #!CommitTicketReference repository="" revision="56595"
 Options, Meta APIs: Optimize get_option by relocating notoptions cache
 lookup.

 In the get_option function, a cache lookup for the notoptions key is
 performed, which stores an array of keys for options known not to exist.
 This optimization prevents repeated database queries when certain options
 are requested. However, the cache lookup for notoptions was conducted
 before checking if the requested option exists in the cache. Given that
 it's more likely that the option does exist, this commit reorders the
 checks to first verify the option's existence in the cache before
 confirming its absence. This adjustment reduces redundant queries and also
 eliminates an unnecessary cache lookup, improving overall performance.

 Props spacedmonkey, costdev, flixos90, azaozz.
 Fixes #58277.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58277#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list