Попробуйте, для начала, заменить зависимый подзапрос
AND (
SELECT count(*)>0
FROM s_variants pv
WHERE pv.product_id=p.id AND pv.price>0
AND (pv.stock IS NULL OR pv.stock>0) LIMIT 1
) = 1
на независимый
AND p.id IN (
SELECT product_id
FROM s_variants
WHERE price > 0 AND (stock IS NULL OR stock > 0)
)