-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 i think the 2 queries are not equivalent. the first one is equivalent to
... WHERE data.guid = 'J7B1X' AND (ISDESCENDANTNODE(data, '/article') plus WHERE ISDESCENDANTNODE(data, '/import/article') (if you want the data.guid = ... to apply to both, you need paranthesis) but if /import/article is almost empty, i still don't see why the combined query should take so long unless jackrabbit/lucene are doing something stupid. cheers,david Am 26.03.2012 22:28, schrieb Christian Stocker: > Hi > > We have the following search query > > > SELECT * FROM [own:unstructured] AS data WHERE data.guid = 'J7B1X' > AND (ISDESCENDANTNODE(data, '/article') > OR ISDESCENDANTNODE(data, '/import/article') > ) > ORDER BY firstImportDate DESC > > > This query can take quite some time (up to 3 seconds, but it gets more > and more hte more data we have). In /article there's potentially a lot > of nodes, in /import/article usually almost nil. > > > If we now separate the query into 2: > > SELECT * FROM [own:unstructured] AS data WHERE data.guid = 'J7B1X' > AND ISDESCENDANTNODE(data, '/article') > ORDER BY firstImportDate DESC > > and > > SELECT * FROM [own:unstructured] AS data WHERE data.guid = 'J7B1X' > AND ISDESCENDANTNODE(data, '/import/article') > ORDER BY firstImportDate DESC > > Both queries take approx. 10ms (and return 0 or 1 resultset, more is not > possible). So quite fast. > > Can anyone explain to me, why that is and how we could rewrite the query > to make it fast with a single one as well? > > Thanks > > chregu - -- Liip AG // Agile Web Development // T +41 26 422 25 11 CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9xZ/sACgkQqBnXnqWBgIu7MwCeOszdHIwKRfM3wQxjj7p1B34/ tRAAoJGC+CZmxKg0M5BoFP3S7/ojv7kF =fEG0 -----END PGP SIGNATURE-----
