MySQL Forums
Forum List  »  Performance

Very slow query when too many joins
Posted by: As Os
Date: June 05, 2016 09:17AM

In my db I have 2 tables:
1.table 'fields_values' with fields: id,field_id(FK to fields table), ads_id(FK to ads table), value.
2.table 'ads' with fields: id,field_id (which actually is in a json format field).

My query is like this:



SELECT DISTINCT a.*,b.value
FROM ads as a

LEFT JOIN fields_values AS b
ON (`b`.`ads_id` = `a`.`id` AND `b`.field_id="183")

LEFT JOIN fields_values AS c
ON (`c`.`ads_id` = `a`.`id` AND `c`.field_id="183")

Up to 25 joins, it's ok.
But on 26, 27 joins it slows down.
On more joins, it slows down dramatically.

How can I fix this?
(I tried to post the EXPLAIN from phpmyadmin but I failed)

Options: ReplyQuote


Subject
Views
Written By
Posted
Very slow query when too many joins
1044
June 05, 2016 09:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.