Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 82824 invoked from network); 17 Dec 2010 10:59:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Dec 2010 10:59:27 -0000 Received: (qmail 87248 invoked by uid 500); 17 Dec 2010 10:59:27 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 87189 invoked by uid 500); 17 Dec 2010 10:59:27 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 87182 invoked by uid 99); 17 Dec 2010 10:59:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Dec 2010 10:59:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Dec 2010 10:59:24 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id oBHAx2qn025380 for ; Fri, 17 Dec 2010 10:59:02 GMT Message-ID: <12209965.175911292583542902.JavaMail.jira@thor> Date: Fri, 17 Dec 2010 05:59:02 -0500 (EST) From: "Serge Huber (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Updated: (JCR-2835) Poor performance of ISDESCENDANTNODE on SQL 2 queries In-Reply-To: <24017189.11441291793941568.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JCR-2835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Serge Huber updated JCR-2835: ----------------------------- Fix Version/s: 2.2.1 > Poor performance of ISDESCENDANTNODE on SQL 2 queries > ----------------------------------------------------- > > Key: JCR-2835 > URL: https://issues.apache.org/jira/browse/JCR-2835 > Project: Jackrabbit Content Repository > Issue Type: Improvement > Components: jackrabbit-core, query > Affects Versions: 2.2.0, 2.2.1, 2.3.0 > Reporter: Serge Huber > Fix For: 2.2.1, 2.3.0 > > Attachments: DescendantSearchTest.png, JCR-2835-use-DescendantSelfAxisQuery.patch, JCR-2835_PerformanceTests.patch, JCR-2835_Poor_performance_on_ISDESCENDANTNODE_constraint_v1.patch, SQL2DescendantSearchTest.png > > > Using the latest source code, I have noticed very bad performance on SQL-2 queries that use the ISDESCENDANTNODE constraint on a large sub-tree. For example, the query : > select * from [jnt:news] as news where ISDESCENDANTNODE(news,'/root/site') order by news.[date] desc > executes in 600ms > select * from [jnt:news] as news order by news.[date] desc > executes in 4ms > From looking at the problem in the Yourkit profiler, it seems that the culprit is the constraint building, that uses recursive Lucene searches to build the list of descendant node IDs : > private Query getDescendantNodeQuery( > DescendantNode dn, JackrabbitIndexSearcher searcher) > throws RepositoryException, IOException { > BooleanQuery query = new BooleanQuery(); > try { > LinkedList ids = new LinkedList(); > NodeImpl ancestor = (NodeImpl) session.getNode(dn.getAncestorPath()); > ids.add(ancestor.getNodeId()); > while (!ids.isEmpty()) { > String id = ids.removeFirst().toString(); > Query q = new JackrabbitTermQuery(new Term(FieldNames.PARENT, id)); > QueryHits hits = searcher.evaluate(q); > ScoreNode sn = hits.nextScoreNode(); > if (sn != null) { > query.add(q, SHOULD); > do { > ids.add(sn.getNodeId()); > sn = hits.nextScoreNode(); > } while (sn != null); > } > } > } catch (PathNotFoundException e) { > query.add(new JackrabbitTermQuery(new Term( > FieldNames.UUID, "invalid-node-id")), // never matches > SHOULD); > } > return query; > } > In the above example this generates over 2800 Lucene queries, which is the culprit. I wonder if it wouldn't be faster to retrieve the IDs by using the JCR to retrieve the list of child IDs ? > This was probably also missed because I didn't seem to find any performance tests on this constraint. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.