WordPress.org

Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #16910


Ignore:
Timestamp:
03/21/2011 01:08:44 AM (7 years ago)
Author:
scribu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16910 – Description

    v1 v2  
    3333But, if you have many many countries (not a good example, I know), you waste a lot of time passing the IDs back and forth from PHP to SQL.
    3434
     35Final query:
     36
     37{{{
     38SELECT *
     39FROM wp_posts
     40WHERE post_type = 'city'
     41AND post_parent IN (1, 2, 3, ...)
     42}}}
     43
    3544It would be a lot more scalable to put the first query into the second, directly, as a subquery.
    3645
     
    6069) );
    6170}}}
     71
     72Final query:
     73
     74{{{
     75SELECT *
     76FROM wp_posts
     77WHERE post_type = 'city'
     78AND post_parent IN (
     79  SELECT ID
     80  FROM wp_posts
     81  WHERE post_type = 'country'
     82  INNER JOIN wp_terms ...
     83)
     84}}}