SELECT product_id, stock_status, currency, brand_name, brand_company_id, product_name, product_image, style_number, price_min AS price, company_participates, MIN(price_min) AS min_price, MAX(price_max) AS max_price, MAX(has_ptp) AS max_has_ptp, MIN(is_dropship) AS is_dropshippable, INTERVAL(price,0,25,50,75,100,150,200,300,500,750,1000) AS price_range, GEODIST(40.0292888, -105.3100174, lat, lng, {in=degrees, out=miles}) AS distance, ANY(x.id = 651 FOR x IN categories) AS has_category FROM locally:product_stores_2 WHERE channel_id = 1 AND brand_company_id = 1697 AND suppress_in_native_domain = false AND (distance < 150 OR stock_status = 0) AND has_category = 1 GROUP BY product_id, currency ORDER BY stock_status desc, popularity_rank desc LIMIT 30 OFFSET 0 OPTION threads=16 FACET store_id ORDER BY COUNT(*) DESC LIMIT 40 FACET brand_company_id ORDER BY COUNT(*) DESC LIMIT 50 FACET category_id_top ORDER BY COUNT(*) DESC LIMIT 10 FACET category_id_2nd ORDER BY COUNT(*) DESC LIMIT 10 FACET category_id_3rd ORDER BY COUNT(*) DESC LIMIT 10 FACET category_id_4th ORDER BY COUNT(*) DESC LIMIT 10 FACET price_range AS pr,currency FACET INTERVAL(avg_rating,0,1,2,3,4) ORDER BY FACET() ASC FACET INTERVAL(distance,0,25,50,100) ORDER BY FACET() ASC FACET has_ptp LIMIT 2 FACET is_sdd LIMIT 2 FACET is_dropship LIMIT 2 FACET gender ORDER BY COUNT(*) DESC LIMIT 20