Opened 3 years ago

Last modified 3 years ago

#11823 new enhancement

Improve SQL query used by get_terms()

Reported by: sirzooro Owned by: filosofo
Priority: normal Milestone: Future Release
Component: Taxonomy Version: 3.0
Severity: normal Keywords: has-patch needs-testing
Cc: kevinB

Description

#11076 / [12658] changes get_terms() so it uses SQL query with multiple conditions in WHERE clause - one for each included / excluded term. It will be better to change generated SQL from:

AND (t.term_id = 1 OR t.term_id = 2 OR ...)
AND (t.term_id <> 1 AND t.term_id <> 2 AND ...)

to:

AND t.term_id IN (1, 2, ...)
AND t.term_id NOT IN (1, 2, ...)

Attachments (2)

taxonomy.php.diff (1.6 KB) - added by sirzooro 3 years ago.
taxonomy.php.2.diff (1.9 KB) - added by sirzooro 3 years ago.
no loops this time

Download all attachments as: .zip

Change History (6)

  • Milestone changed from 3.0 to Future Release
  • Cc kevinB added
  • Keywords has-patch needs-testing added; needs-patch removed

OK, looks that I have to provide a patch for this :)

comment:4   dd323 years ago

instead of those ugly loops, something similar to this might be possible?

$interms = array_map('intval', $interms);
$inclusions = ' AND t.term_id IN ( ' . implode(',', $interms) . ' )';

(note, Untested, and havnt looked at the code closer than the patch)

no loops this time

Note: See TracTickets for help on using tickets.