[
https://issues.apache.org/jira/browse/OAK-12494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thomas Mueller updated OAK-12494:
---------------------------------
Description:
The query restriction "name()=''" is not currently pushed down to the index (it
is ignored when building the filter for the index). So that the index can
return many results, which are then later filtered out by the query engine.
The root node is the only node with an empty name.
We can use this knowledge instead of dropping the restriction (which will allow
too many results).
Since only the root node has an empty name, Oak can instead restrict the query
to exactly "/" . Combined with a path condition that excludes the root, the
query cannot return any results.
Example:
{noformat}
SELECT * FROM [nt:base] WHERE NAME() = ''
=> only the root node
SELECT * FROM [nt:base] WHERE NAME() = '' AND ISDESCENDANTNODE('/')
=> can not have any results, because ISDESCENDANTNODE excludes the root node
{noformat}
Same for LOCALNAME().
was:
A query with a "name()=''" restriction ignores this restriction.
The root node is the only node with an empty name.
We can use this knowledge instead of dropping the restriction (which will allow
too many results).
Example:
{noformat}
SELECT * FROM [nt:base] WHERE NAME() = ''
=> only the root node
SELECT * FROM [nt:base] WHERE NAME() = '' AND ISDESCENDANTNODE('/')
=> can not have any results, because ISDESCENDANTNODE excludes the root node
{noformat}
Same for LOCALNAME().
> Index usage of NAME()='' (with empty value)
> -------------------------------------------
>
> Key: OAK-12494
> URL: https://issues.apache.org/jira/browse/OAK-12494
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Reporter: Thomas Mueller
> Assignee: Thomas Mueller
> Priority: Major
>
> The query restriction "name()=''" is not currently pushed down to the index
> (it is ignored when building the filter for the index). So that the index can
> return many results, which are then later filtered out by the query engine.
> The root node is the only node with an empty name.
> We can use this knowledge instead of dropping the restriction (which will
> allow too many results).
> Since only the root node has an empty name, Oak can instead restrict the
> query to exactly "/" . Combined with a path condition that excludes the
> root, the query cannot return any results.
> Example:
> {noformat}
> SELECT * FROM [nt:base] WHERE NAME() = ''
> => only the root node
> SELECT * FROM [nt:base] WHERE NAME() = '' AND ISDESCENDANTNODE('/')
> => can not have any results, because ISDESCENDANTNODE excludes the root node
> {noformat}
> Same for LOCALNAME().
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)