You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Seidel. Robert" <Ro...@aeb.de> on 2010/08/18 15:02:14 UTC
Slow sql query performance (against xpath)
Hi,
this code:
QueryManager qm = session1.getWorkspace().getQueryManager();
Query q = null;
String queryString = "//*[@a_filename = '" + "1761.pdf" + "']";
q = qm.createQuery(queryString, Query.XPATH);
System.out.println((new GregorianCalendar()).getTimeInMillis()+" XPath Query created...");
QueryResult result = q.execute();
System.out.println((new GregorianCalendar()).getTimeInMillis()+" XPath Query performed...");
Produced:
1282136144493 XPath Query created...
1282136144509 XPath Query performed...
= 16 milliseconds
The same sql code:
QueryManager qm = session1.getWorkspace().getQueryManager();
Query q = null;
String queryString =
"select * from [nt:base] where a_filename = '1761.pdf'";
q = qm.createQuery(queryString, Query.JCR_SQL2);
System.out.println((new GregorianCalendar()).getTimeInMillis()+" Query created...");
QueryResult result = q.execute();
System.out.println((new GregorianCalendar()).getTimeInMillis()+" Query performed...");
Produced:
1282136145509 Query created...
1282136256319 Query performed...
= 110810 milliseconds
What can I do, to get nearly the same performance with sql as I get with XPath?
Kindly regards,
Robert Seidel
Re: Slow sql query performance (against xpath)
Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Aug 18, 2010 at 15:29, Seidel. Robert <Ro...@aeb.de> wrote:
> Thanks Jukka,
>
> this helped a lot.
>
> I wouldn't ask, why Query.SQL is deprecated, when Query.JCR_SQL2 can't be used due to performance issues :p
It's deprecated in the JCR 2.0 specification, optimization is up to
the implementation (ie. Jackrbabit). Jackrabbit will continue to
support Xpath and SQL as these are still the most used query languages
in JCR applications, afaics.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
AW: Slow sql query performance (against xpath)
Posted by "Seidel. Robert" <Ro...@aeb.de>.
Thanks Jukka,
this helped a lot.
I wouldn't ask, why Query.SQL is deprecated, when Query.JCR_SQL2 can't be used due to performance issues :p
Kindly regards,
Robert Seidel
-----Ursprüngliche Nachricht-----
Von: Jukka Zitting [mailto:jukka.zitting@gmail.com]
Gesendet: Mittwoch, 18. August 2010 15:06
An: users@jackrabbit.apache.org
Betreff: Re: Slow sql query performance (against xpath)
Hi,
On Wed, Aug 18, 2010 at 3:02 PM, Seidel. Robert <Ro...@aeb.de> wrote:
> q = qm.createQuery(queryString, Query.JCR_SQL2);
Use this instead:
q = qm.createQuery(queryString, Query.SQL);
The JCR_SQL2 support in Jackrabbit is tied to our join implementation,
which hasn't yet be optimized for performance (see also JCR-2715).
BR,
Jukka Zitting
Re: Slow sql query performance (against xpath)
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Wed, Aug 18, 2010 at 3:02 PM, Seidel. Robert <Ro...@aeb.de> wrote:
> q = qm.createQuery(queryString, Query.JCR_SQL2);
Use this instead:
q = qm.createQuery(queryString, Query.SQL);
The JCR_SQL2 support in Jackrabbit is tied to our join implementation,
which hasn't yet be optimized for performance (see also JCR-2715).
BR,
Jukka Zitting