Дело в том, что при исполнении такого запроса
( SELECT MAX ( discount_price ) FROM OPTIONS WHERE products.ID = OPTIONS.product_id ) AS max_price
очень медленно работает:
SELECT options.product_id,
( SELECT MAX ( discount_price ) FROM OPTIONS WHERE products.ID = OPTIONS.product_id ) AS max_price,
products.slug,
products.NAME AS NAME,
products.ID AS ID,
products.picture_id,
meta_id,
products.description AS description,
updated_at,
purchases,
priority
FROM
"products"
LEFT JOIN "options" ON "options"."product_id" = "products"."id"
WHERE "products"."product_status_id" = 1
AND "options"."active" = true
AND "products"."deleted_at" IS NULL
GROUP BY
"products"."id",
"options"."product_id"
ORDER BY
"max_price" ASC
LIMIT 24