[
https://issues.apache.org/jira/browse/OAK-1263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13915817#comment-13915817
]
Davide Giannella commented on OAK-1263:
---------------------------------------
Attached the .patch with an initial implementation and following the
pull request as it will be probably easier for inspection.
https://github.com/apache/jackrabbit-oak/pull/9
What's NOT YET implemented:
1) Descending order
2) The "Skip" part of the SkipList
3) getCost(). The cost part is related to changes needed to the
QueryEngine (see below)
4) The pagination and offset can in theory be provided by the index as
it's ordered but as the index itself doens't have knowledge around
ACLs it has to leverage the task to the QueryEngine. it will be
probably faster to achieve the same by using the Iterator.skip().
In order to use it you can create an index definition like the
following:
{code}
{
"jcr:primaryType" : "oak:QueryIndexDefinition",
"reindex" : false,
"propertyNames" : "jcr:lastModified",
"type" : "ordered"
}
{code}
QueryEngine changes
===================
In order to use it we'll need to change the QueryEngine (QE) API so that
the ORDER BY bits of the query are passed down to the index for having
proper cost/plan and the index should pass up to the QE the
information about: "you don't have to sort, it's done for you".
Benchmarks
==========
The implementation is provided with benchmarks for assessing the
differences between three use-cases: no-index, PropertyIndex,
OrderedPropertyIndex.
Attached the output of benchmarks from my laptop:
benchmark-20140228112150.log is the insert of nodes from 0 to N
benchmark-20140228120718.log is the insert of 100 nodes on top of N
benchmark-20140228125248.log is the query executed with N nodes in the
index
> optimize oak index to support 'fast ORDER BY' queries to support sorting &
> pagination for large set of children
> ---------------------------------------------------------------------------------------------------------------
>
> Key: OAK-1263
> URL: https://issues.apache.org/jira/browse/OAK-1263
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: query
> Affects Versions: 0.12
> Reporter: Stefan Egli
> Assignee: Alex Parvulescu
> Fix For: 0.18
>
>
> We have a use case where we'd like to be able to use an index in a
> "pagination-like" fashion. That is, we'd like to be able to have an index on
> a subtree on a certain property, and then run a query which does ORDER BY
> that property combined with OFFSET. That way, essentially allowing pagination
> of child nodes of a particular parent based on 'sorted by a certain property'.
> AFAIU currently the oak index is not optimized to support ORDER BY queries in
> a fast manner. The index keeps 'the child nodes unsorted', ie to process an
> ORDER BY, the child nodes would have to be 'manually sorted' which can result
> in bad performance given a large number of child nodes.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)