[wp-trac] [WordPress Trac] #63683: Improve wp_insert_term() duplicate query
WordPress Trac
noreply at wordpress.org
Thu Jul 10 22:33:31 UTC 2025
#63683: Improve wp_insert_term() duplicate query
-------------------------+-----------------------------
Reporter: xipasduarte | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: minor | Keywords:
Focuses: performance |
-------------------------+-----------------------------
The query in `wp_insert_term()` to get the `$duplicate_term` is fetching
all matching terms from the database and extracting the first afterwords.
If there is an issue and terms are created with duplicate slugs in large
amounts, the query becomes slow, not just due to the amount of
comparisons, but also the data being returned. Both aspects could be
improved with a `LIMIT 1` appended to the query.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63683>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list