jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Byrne <step...@lincware.com>
Subject Efficiency of query matching child's property
Date Thu, 11 Aug 2011 13:12:40 GMT
I am writing a query that selects nodes based on their children's 
property values.

The node I want to select looks like this (among many others nodes with 
the same structure but different property values):
/myItem (sb:item)
.a (sb:itemChild)
..@sb:value = "one"
.b (sb:itemChild)
..@sb:value = "two"
.c (sb:itemChild)
..@sb:value = "three"

XPath:
//element(*,sb:item)[a/sb:value="one" and b/sb:value="two"]

If using SQL2 or QOM it seems I have to separate some of the join 
conditions to the where clause, which has got to be pretty inefficient:

SELECT *
FROM [sb:item] AS [item]
INNER JOIN [sb:itemChild] AS [childA] ON ISCHILDNODE( [childA], [item] )
INNER JOIN [sb:itemChild] AS [childB] ON ISCHILDNODE( [childB], [item] )
WHERE
NAME([childA]) = "a" // logically part of first join
AND
[childA].[sb:value] = "one" // logically part of the first join
AND
NAME([childB]) = "b" // logically part of second join
AND
[childB].[sb:value] = "two" // logically part of the second join

I realize in this simple case a, b, and c could be properties of myItem, 
which would drastically simply and speed up the query. My actual model 
has more complex subtrees for a, b, and c.

Is there a way to have multiple conditions for a join and I just missed it?

Is XPath parsed to a similar QOM tree?

-- 
Stephen Byrne
LincWare, LLC
stephen@lincware.com

Mime
View raw message