Dear Nuria,

Am 18.02.2013 16:39, schrieb Nuria Garcia:
> Thanks for your quick answer.

sorry for taking so long this time...

> One more question, in a similar query but with attributes, it looks like the 
> index doesn´t get applied (more similar to our real situation):

> Compiling:
> - rewriting where clause to predicate(s)
> - pre-evaluating db:open("bbdd_1")
> - simplifying descendant-or-self step(s)
> - converting descendant::*:businessEvent to child steps
> - pre-evaluating db:open("bbdd_2")
> - simplifying descendant-or-self step(s)
> - simplifying descendant-or-self step(s)
> - swapping operands: descendant::*:inputs/.../fn:data(@*:element) = 
> $col1/descendant::inputs/.../fn:data(@element)
> - simplifying descendant-or-self step(s)
> - converting descendant::*:businessEvent[...] to child steps
> - simplifying descendant-or-self step(s)

> Is it possible that the index doesn’t get applied?, how could I improve this 
> query?

Yes, the index is not applied, otherwise there would be the line
"applying attribute index" in the compilation info. That is because of
the calls to `fn:data()` around the attribute steps in the `where`
clause. These are unnecessary and hide the attribute comparisons from
the optimizer. Removing them triggers the optimization in my tests.

Hope that helps,
  cheers, Leo

BTW: The XML example you posted looks quite "enterprisey" and ignores
quite some XML best-practices. Its structure could easily confuse the
query optimizer because of all the attribute/text comparisons. If you
have any influence on the structure of your data, it would probably be
beneficial to encode the `@name` attributes as element names, which are
currently all the same anyways. The result could look something like this:

<data>
  <id>229388252</id>
  <matriculation>2751 XTE</matriculation>
  <clientId>XTETVTTJKC</clientId>
  <driver>
    <name>driver name</name>
    <surname>driver surname</surname>
    <nif>21973887X</nif>
    <line1>line 1</line1>
    <line2>Line 2</line2>
    <city>City name</city>
    <cp>28197</cp>
    <region>Region7</region>
    <country>Country</country>
  </driver>
  <accident>
    <date>
      <year>2012</year>
      <month>13</month>
      <day>22</day>
      <hour>2</hour>
      <minute>53</minute>
    </date>
    <address>
      <line1>Avenue 5</line1>
      <line2>Line2</line2>
      <city>Madrid</city>
      <cp>28224</cp>
      <region>Region3</region>
      <country>Spain</country>
    </address>
    <declaration>Lorem ipsum dolor ....</declaration>
  </accident>
</data>


_______________________________________________
BaseX-Talk mailing list
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to