Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scaling WordPress Queries With Elasticsearch

xyu
May 19, 2015

Scaling WordPress Queries With Elasticsearch

xyu

May 19, 2015
Tweet

More Decks by xyu

Other Decks in Technology

Transcript

  1.  18,600,000,000
 409,000,000 56,000,000
 68,000,000 5,000
 1 Page Views
 Unique

    Visitors
 New Posts
 New Comments
 Deploys
 WordPress Multisite
  2. new WP_Query( array( 'tax_query' => array( array( 'taxonomy' => 'beer_style',

    'field' => 'slug', 'terms' => array( 'ipa', 'pale' ), ) ) ) );
  3. SELECT wp_term_taxonomy.term_id FROM wp_term_taxonomy INNER JOIN wp_terms USING ( term_id

    ) WHERE taxonomy = 'beer_style' AND wp_terms.slug IN ( 'ipa', 'pale' )
  4. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (

    wp_posts.ID = wp_term_relationships.object_id ) WHERE 1=1 AND wp_term_relationships.term_taxonomy_id IN ( 5, 7 ) AND wp_posts.post_type = 'post' AND … GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 25
  5. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (

    wp_posts.ID = wp_term_relationships.object_id ) WHERE 1=1 AND wp_term_relationships.term_taxonomy_id IN ( 5, 7 ) AND wp_posts.post_type = 'post' AND … GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 25 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships wp_posts.ID = wp_term_relationships.object_id ) WHERE 1=1 wp_term_relationships.term_taxonomy_id wp_posts.post_type = … GROUP BY wp_posts.ID ORDER BY wp_posts.post_date LIMIT 0, 25
  6. SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID

    = wp_postmeta.post_id ) WHERE wp_postmeta.meta_key = 'hops' AND wp_postmeta.meta_value IN ( 'Amarillo', 'Calypso' )
  7. wp_postmeta.meta_value IN ( 'Amarillo', 'Calypso' ) SELECT wp_posts.* FROM wp_posts

    INNER JOIN wp_postmeta wp_posts.ID = wp_postmeta.post_id WHERE wp_postmeta.meta_key = wp_postmeta.meta_value
  8. new WP_Query( array( 'tax_query' => array( array( 'taxonomy' => 'beer_style',

    'field' => 'slug', 'terms' => array( 'ipa', 'pale' ), ) ) ) );
  9. POST /es-index/post/_search { "query": { "filtered": { "filter": { "bool":

    { "must": [ { "terms": { "taxonomy.beer_style.slug": [ "ipa", "pale" ] } } ] } } } } }