jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: XPath query performance yet another time.
Date Wed, 13 Feb 2008 15:05:21 GMT
Alex Lukin wrote:
> 3.  "//element(my:topic)"  - 4.3 seconds. (was 12)

I've created a test case that generates 3 levels of 'category' nodes and 10 
'topic' nodes in each leaf category. This results in 640 topics.

     public void testPerformance() throws RepositoryException {
         int topicCount = 0;
         for (int i = 0; i < 4; i++) {
             Node cat1 = testRootNode.addNode("cat" + i);
             for (int j = 0; j < 4; j++) {
                 Node cat2 = cat1.addNode("cat" + j);
                 for (int k = 0; k < 4; k++) {
                     Node cat3 = cat2.addNode("cat" + k);
                     for (int l = 0; l < 10; l++) {
                         cat3.addNode("topic");
                         cat3.setProperty("prop", topicCount++);
                     }
                 }
             }
         }
         testRootNode.save();
         for (int i = 0; i < 10; i++) {
             long time = System.currentTimeMillis();
             NodeIterator it = executeQuery("//element(topic)").getNodes();
             time = System.currentTimeMillis() - time;
             System.out.print("executed in " + time + " ms");
             time = System.currentTimeMillis();
             int count = 0;
             while (it.hasNext()) {
                 it.nextNode();
                 count++;
             }
             time = System.currentTimeMillis() - time;
             System.out.println(", looped over " + count + " result nodes in " + 
time + " ms");
         }
     }

The output is:

executed in 422 ms, looped over 640 result nodes in 312 ms
executed in 31 ms, looped over 640 result nodes in 235 ms
executed in 15 ms, looped over 640 result nodes in 250 ms
executed in 16 ms, looped over 640 result nodes in 234 ms
executed in 16 ms, looped over 640 result nodes in 250 ms
executed in 16 ms, looped over 640 result nodes in 250 ms
executed in 15 ms, looped over 640 result nodes in 235 ms
executed in 0 ms, looped over 640 result nodes in 234 ms
executed in 16 ms, looped over 640 result nodes in 234 ms
executed in 16 ms, looped over 640 result nodes in 234 ms


this first execution is slow because caches are not initialized, subsequent 
queries however are between 10 and 15 milliseconds.

please note that my setup is an model 1, but that shouldn't actually make a 
difference, because model 2 also uses the repository in process.

can you please post your workspace.xml configuration?

regards
  marcel

Mime
View raw message