MySQL Forums
Forum List  »  Optimizer & Parser

Optimize subquery, replace IN() with JOIN
Posted by: Miron jajtic
Date: November 15, 2016 02:37PM

Hello,

I have sql query with two in() subqueries, they are returning correct 10 sorted results, but complete query it's terrible slow, over 5 minutes waiting.

SELECT id, title, alias
FROM content
WHERE published = '1'
AND typ = 'actual'
AND id
IN (
SELECT content_id
FROM category_content_se
WHERE category_id
IN (
SELECT category_id
FROM category_content_se
WHERE content_id = '11430'
)
AND content_typ = 'actual'
)
ORDER BY date_add DESC
LIMIT 10


Can someone please help me how to write same query using JOINs ?

Server is MySQLv5.6

Options: ReplyQuote


Subject
Views
Written By
Posted
Optimize subquery, replace IN() with JOIN
2170
November 15, 2016 02:37PM


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.