Hey
I have a query similar to this
FROM products AS p, ..
LEFT JOIN ( SELECT .. ) AS popularity on popularity.products_id = p.products_id
LEFT JOIN ( SELECT .. ) AS reviews on reviews.products_id = p.products_id
WHERE..
AND..
..
The nested SELECT
s from the LEFT JOIN
are static, I mean the returned result is not influenced by external values. Those two SELECT
s use data from within the db and calculate a result. The results of these queries change rarely, when some user makes a review for a product for example.
The problem is that these SELECT
s take a lot of time to complete, they go through each row of their respective tables.
Is there a way I could make this query faster by transforming it into several smaller queries? Or caching the nested selects in some way?