Subject | RE: [firebird-support] Firebird 2.5: Optimize of IN or EXISTS performance |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-11-15T08:36:19Z |
>SELECT * FROM ARTICLE_CONTENTTREE_LINK WHERE ARTICLEID inI don't think these two queries could easily use an index for both tables (I think it could be implemented since the subqueries aren't correlated, but I don't think accommodating for lazy development should be put high on any priority list - though note that I don't know whether it has been implemented or not).
>(Select RELID FROM ARTICLE WHERE DEFINEID=112435)
>
>SELECT * FROM ARTICLE_CONTENTTREE_LINK
>WHERE EXISTS
> (Select RELID FROM ARTICLE WHERE DEFINEID=112435
>AND ARTICLE.RELID=ARTICLE_CONTENTTREE_LINK.ARTICLEID)
Modify your query a bit, and it should use your indexes:
WITH ARTICLE2 AS
(SELECT DISTINCT RELID
FROM ARTICLE WHERE DEFINEID=112435)
SELECT A.*
FROM ARTICLE_CONTENTTREE_LINK A
JOIN ARTICLE2 A2 ON A.ARTICLEID=A2.RELID)
HTH,
Set