[ 
https://issues.apache.org/jira/browse/OAK-419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Mueller updated OAK-419:
-------------------------------

    Description: 
Currently the query plan for the following query

{code}
select * from [nt:base] as c 
right outer join [nt:base] as p on p.id = c.p 
where p.id is not null 
and isdescendantnode(p, '/testRoot') 
and isdescendantnode(c, '/testRoot')
{code}

is:

{code}
[nt:base] as [p] 
/* traverse "/testRoot//*" 
where (([p].[id] is not null) 
and (isdescendantnode([p], [/testRoot]))) 
and ([p].[id] is not null) */ 
left outer join [nt:base] as [c] 
/* traverse "//*" 
where (isdescendantnode([c], [/testRoot])) 
and ([c].[p] is not null) */ 
on [p].[id] = [c].[p]
{code}

Because of that, far too many nodes are traversed on "c".
Instead, the isdescendantnode condition should be pused to "c" so that
it only traverses "/testRoot//*".

The result of the query is still correct, but performance is potentially very 
bad (even if there is an index).

  was:
Currently the query plan for the following query

    select * from [nt:base] as c 
    right outer join [nt:base] as p on p.id = c.p 
    where p.id is not null 
    and isdescendantnode(p, '/testRoot') 
    and isdescendantnode(c, '/testRoot')

is:

    [nt:base] as [p] 
    /* traverse "/testRoot//*" 
    where (([p].[id] is not null) 
    and (isdescendantnode([p], [/testRoot]))) 
    and ([p].[id] is not null) */ 
    left outer join [nt:base] as [c] 
    /* traverse "//*" 
    where (isdescendantnode([c], [/testRoot])) 
    and ([c].[p] is not null) */ 
    on [p].[id] = [c].[p]

Because of that, far too many nodes are traversed on [c].
Instead, the isdescendantnode condition should be pused to [c] so that
it only traverses "/testRoot//*".

The result of the query is still correct, but performance is potentially very 
bad (even if there is an index).

    
> Query: Conditions are not pushed to "outer join" selectors
> ----------------------------------------------------------
>
>                 Key: OAK-419
>                 URL: https://issues.apache.org/jira/browse/OAK-419
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>            Priority: Minor
>
> Currently the query plan for the following query
> {code}
> select * from [nt:base] as c 
> right outer join [nt:base] as p on p.id = c.p 
> where p.id is not null 
> and isdescendantnode(p, '/testRoot') 
> and isdescendantnode(c, '/testRoot')
> {code}
> is:
> {code}
> [nt:base] as [p] 
> /* traverse "/testRoot//*" 
> where (([p].[id] is not null) 
> and (isdescendantnode([p], [/testRoot]))) 
> and ([p].[id] is not null) */ 
> left outer join [nt:base] as [c] 
> /* traverse "//*" 
> where (isdescendantnode([c], [/testRoot])) 
> and ([c].[p] is not null) */ 
> on [p].[id] = [c].[p]
> {code}
> Because of that, far too many nodes are traversed on "c".
> Instead, the isdescendantnode condition should be pused to "c" so that
> it only traverses "/testRoot//*".
> The result of the query is still correct, but performance is potentially very 
> bad (even if there is an index).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to