[wp-trac] [WordPress Trac] #39826: LIMIT clause not required in get_options function as there's already a UNIQUE KEY on option_name
WordPress Trac
noreply at wordpress.org
Thu Feb 9 23:41:07 UTC 2017
#39826: LIMIT clause not required in get_options function as there's already a
UNIQUE KEY on option_name
-------------------------+-----------------------------
Reporter: arjenlentz | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.2
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The Core get_options (wp-includes/option.php) uses LIMIT 1 to retrieve
only a single row for an option.
However, the option_name field already has a UNIQUE KEY in the table
schema, so it's impossible for the db to contain or return more than one
row for any option_name.
Barring history I'm unaware of (if there used to not be a UNIQUE KEY on
this field in the past), it's safe to remove the LIMIT 1 clauses from
these queries (there are a few instances in the function.
While LIMIT clauses can sometimes be harmful to performance, in this
particular scenario that's not the case. However, it's just superfluous.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39826>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list