这个查询很慢,我正在寻找一种优化的方法。
有任何想法吗?
select *,
(rating / (select max(rating) from products)) rk_rating, (reviews /
(select max(reviews) from products)) rk_reviews,
(if(label = "", 0, 1)) rk_label,
(1 - price / (select max(price) from products)) rk_price
from `products`
where (`locale` = 'it' or `locale` = '*')
and `id` in (select `product_id`
from `location_product`
where `location_product`.`location_id` in (select `id`
from `locations`
where `place_id` = 'ChIJdd4hrwug2EcRmSrV3Vo6llI' or `city_place_id` = 'ChIJdd4hrwug2EcRmSrV3Vo6llI'))
order by (rk_rating * '2' + rk_reviews * '5' + rk_label * '0.5' + rk_price * '50') desc limit 21 offset