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

Thomas Mueller commented on OAK-4888:
-------------------------------------

http://svn.apache.org/r1765583 (trunk)

By default, queries without index will log a warning as follows: "Traversal 
query (query without index): {statement}; consider creating an index". Remark: 
no warning is logged if an index is available, but traversing is cheap (because 
there are currently not that many nodes in the specified path).

There is a way to make those queries without index throw an exception instead 
of just logging a warning, by setting the JMX QueryEngineSettings.failTraversal 
to true.

In the query itself the syntax "option(traversal {ok|fail|warn})" is supported 
(at the very end of the statement, after "order by"). This is to override the 
default setting, for queries that traverse a well known number of nodes (for 
example 10 or 20 nodes). This is supported for both XPath and SQL-2, as follows:

{noformat}
/jcr:root/oak:index/*[@type='lucene'] option(traversal ok)

select * from [nt:base] 
where ischildnode('/oak:index') 
order by name()
option(traversal ok)
{noformat}



> Warn or fail queries above a configurable cost value
> ----------------------------------------------------
>
>                 Key: OAK-4888
>                 URL: https://issues.apache.org/jira/browse/OAK-4888
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: query
>            Reporter: Alexander Klimetschek
>            Assignee: Thomas Mueller
>             Fix For: 1.6
>
>
> *Problem:* It's easy to run into performance problems with queries that are 
> not backed by an index or miss the right one. Developers writing these 
> queries typically do not have the real large production data, and thus don't 
> see that a query would scale badly, and would not see any traversal warnings, 
> as these only happen with a large number of results.
> *Proposal:* Oak's query engine already calculates a cost estimate to make a 
> decision which index to use, or even if there is any at all. This cost 
> estimate could be used to find out if a query is not supported by an index or 
> with one that is not suitable enough (e.g. ordering by property that is not 
> indexed)
> If a query is above a certain cost value, a big warning could be put out or 
> even the query could be made to fail (maybe a per query option, that you 
> might want to have to "fail" by default to ensure people are not overlooking 
> the problem). The cost limit should be configurable, as it might depend on 
> the hardware power.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to