[ 
https://issues.apache.org/jira/browse/OAK-7897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689322#comment-16689322
 ] 

Thomas Mueller commented on OAK-7897:
-------------------------------------

In theory, "UNION" might be faster than "IN" for a few (rare) cases, for 
example:

{noformat}
SELECT [rep:facet(text)] FROM [nt:base] WHERE ([jcr:primaryType] = 'cqDam' OR 
[jcr:primaryType] = 'cqPage')  and ...
{noformat}

I'm not fully sure if there are other cases where UNION might be better.

What I think might be a problem, and I need to test this, is if there are many 
many OR conditions, of the form 

{noformat}
[name]='a' OR [name]='b' OR [name]='c' OR [name]='d' OR ...
{noformat}

Possibly we try out too many variants, so planning might be slow. A workaround 
is to use "IN" in the query directly.

> Queries with OR simplified to IN shouldn't have alternative UNION query
> -----------------------------------------------------------------------
>
>                 Key: OAK-7897
>                 URL: https://issues.apache.org/jira/browse/OAK-7897
>             Project: Jackrabbit Oak
>          Issue Type: Sub-task
>          Components: lucene
>            Reporter: Vikas Saurabh
>            Assignee: Thomas Mueller
>            Priority: Minor
>
> Queries like {noformat} SELECT [rep:facet(text)] FROM [nt:base] WHERE [name] 
> = 'Node1' OR [name] = 'Node2' {noformat} which would get simplified to {{IN}} 
> clause still weigh in cost of alternative query with {{UNION}}. We should 
> avoid that.
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to