tonyalaribe / mybonways

View promos from stores around you
https://mybonways.com
0 stars 1 forks source link

getting the comments and favourites should be part the query, using something like joins #90

Closed tonyalaribe closed 7 years ago

tonyalaribe commented 7 years ago

As mentioned in the slack conversation, its performance degrading to loop over the result and performance queries per result row. Instead, figure out how to integrate it into each of the search queries query.

SELECT id, created_at, updated_at,company_id, item_name, category, old_price, new_price, start_date, end_date, description, promo_images, featured_image, featured_image_b64, slug, neighbourhood, city, country, longitude, latitude FROM merchant_promos x RIGHT OUTER JOIN ( SELECT company_id as cid,neighbourhood,city,country,longitude,latitude FROM branches GROUP BY company_id,neighbourhood,city,country,longitude,latitude ) y ON x.company_id = y.cid WHERE x.category=? ORDER BY x.created_at desc LIMIT ? OFFSET ?