[xml] How to speed up xpath eval with a lot of OR expression


[sending again in case lost]

Still fairly new to XML and libxml2.  So pardon me if this is a
trivial question.

We are generating a xapth consisting of a lot of OR for selecting
child nodes based on the name.

  ex.  /config/group/[name = "n1" or name="n3" or name="n7" ....]

In one instance there are about 17500 "name = value" pairs in the predicate.

xmlXPathEvalExpression() of the above xpath takes a long time with gprof data:

This is with 2.7.7:

time   seconds   seconds    calls   s/call   s/call  name
 20.02      1.93     1.93    14007     0.00     0.00  xmlXPathCompOpEval
 10.27      2.92     0.99 22980128     0.00     0.00  xmlXPathNodeCollectAndTest
  5.39      3.44     0.52 162363242     0.00     0.00  valuePush
  4.56      3.88     0.44 113629376     0.00     0.00  xmlStrEqual

I also tried with 2.9.0 and did not see much difference.

I would appreciate any suggestion on how to improve this xpath query

I saw reference to XQuery (indexed) and wondering if that is really what I need.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]