Skip to content

Instantly share code, notes, and snippets.

@barrychapman
Created March 26, 2014 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrychapman/6efca394242ca685cb5a to your computer and use it in GitHub Desktop.
Save barrychapman/6efca394242ca685cb5a to your computer and use it in GitHub Desktop.
explain SELECT
`PopularProduct` . *,
`Category` . *,
`Product`.`id`,
`Product`.`store_id`,
`Product`.`name`,
`Product`.`price`,
`Product`.`slug`,
`Product`.`like_count`,
`Product`.`comments_count`,
`Product`.`actual_published_date`,
`Product`.`is_featured`,
`Product`.`modified`,
`Product`.`is_on_sale`,
`ProductsAttachment` . *,
`Product`.`is_published`,
`Product`.`created`,
`ProductsDefaultImage` . *,
`MediaType` . *,
`Store` . *
FROM
`offbeatrdb_prod`.`store_popular_products` AS `PopularProduct`
inner JOIN
`offbeatrdb_prod`.`store_products` AS `Product` ON (NOT (`PopularProduct`.`product_id` IS NULL)
AND `Product`.`id` = `PopularProduct`.`product_id`
AND `Product`.`is_published` = 1)
inner JOIN
`offbeatrdb_prod`.`store_products_attachments` AS `ProductsAttachment` ON (`Product`.`id` = `ProductsAttachment`.`product_id`)
inner JOIN
`offbeatrdb_prod`.`store_store` AS `Store` ON (`Store`.`id` = `Product`.`store_id`
AND `Store`.`is_open` = 1)
inner JOIN
`offbeatrdb_prod`.`store_products_sample_images` AS `ProductsDefaultImage` ON (`ProductsDefaultImage`.`is_primary` = 1
AND `ProductsDefaultImage`.`product_id` = `Product`.`id`)
inner JOIN
`offbeatrdb_prod`.`store_product_media_types` AS `MediaType` ON (`MediaType`.`id` = `Product`.`media_type_id`)
inner JOIN
`offbeatrdb_prod`.`store_product_categories` AS `Category` ON (`Category`.`slug` = 'masturbation'
AND `Category`.`id` = `PopularProduct`.`category_id`)
WHERE
1 = 1
GROUP BY `PopularProduct`.`product_id`
ORDER BY `PopularProduct`.`rank` ASC
LIMIT 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment