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

Vikas Saurabh commented on OAK-7897:
------------------------------------

[~tmueller], I understand why a flow of getting the query in description via 
{{QueryEngineImpl#parseQuery}} \[0] is giving original query with {{IN}} clause 
and an alternative {{UNION}} version. The situation is (I don't know if it's 
really an issue or not) is that {{parseQuery}} parses the query via 
{{SQL2Parser}} with {{init=false}} \[1]. This keeps the original query as is 
(with {{OR}} clause). This query when optimized for {{UNION}} indeed gives an 
alternate version. Both of these queries are then init-ed \[2].

If this issue is considered worth solving, then the only way I can think of is 
to initialize the query during parsing itself. That would result in original 
query to be converted with one with {{IN}} clause and hence the optimized query 
would not have a {{UNION}}.

All that said, I'm really not comfortable of why the code is the way it is 
currently. So, [~tmueller], it'd be great if you can pick this one up - it is 
way outside of my comfort zone.

\[0]: 
https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java#L144
\[1]: 
https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java#L174
\[2]: 
https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java#L219

> 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: Vikas Saurabh
>            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