I'm currently trying to run the following query:
SELECT * FROM villas LEFT OUTER JOIN pricing ON villas.id = pricing.id WHERE availability = 1 AND villas.beds > 0 AND (
pricing.price BETWEEN 2000 AND 2500
) GROUP BY villas.id
At the moment the query is running at around 29 secs to execute, if I drop the GROUP BY I can reduce the query down to around 8 secs, which although not great is alot better.
My problem is I am joining 2 tables (villas and pricing), villas contains 1 entry per whilst pricing includes 52 entries per villa and without grouping them I am struggling to return only 1 result per villa.
Any ideas?