IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

XQuery with >, <, gt, lt too slow

  • 1.  XQuery with >, <, gt, lt too slow

    Posted Tue January 16, 2007 03:40 PM

    Hi,

    We have a doctype with an index defined over three fields (obra, par and posPar). The following XQuery
    for $a in input()/A
    where $a/obra=398 and $a/par=557 and $a/posPar>=2
    return $a

    is very slow, while this one:
    for $a in input()/A
    where $a/obra=398 and $a/par=557 and $a/posPar = (2, 3, 4, 5, 6, 7, 8, 9)
    return $a

    is executed inmediately.

    The problem is the “>” operand (or “>=” or “ge”) What’s the correct way to write the first XQuery?

    Thanks in advance?


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: XQuery with >, <, gt, lt too slow

    Posted Tue January 16, 2007 09:37 PM

    Hi Pau,
    A few extra info’s would be interesting:

    1. what datatype and indextype has posPar ?
    • is there an index ?
    1. how many instances are there with values beyond 9 ?
    • is the bulk of of hits > 9 then the explanation would be obvious :wink:

    regards
    Finn


    #Tamino
    #API-Management
    #webMethods


  • 3.  RE: XQuery with >, <, gt, lt too slow

    Posted Wed January 17, 2007 11:41 AM

    Hi Finn,

    1. what datatype and indextype has posPar ?
      The datatype is xs:integer and the indextype is standard
    • is there an index ? Yes.
    1. how many instances are there with values beyond 9? There are 8 (2, 3, 4, 5, 6, 7, 8 and 9)

    The result set should be the same. I don’t understand this extremely slow behavior for “the same” XQuery…

    regards,


    #Tamino
    #API-Management
    #webMethods


  • 4.  RE: XQuery with >, <, gt, lt too slow

    Posted Mon January 22, 2007 10:25 AM

    Hi Pau,
    So you mean there are no posPar values higher than 9 ?
    What does the “explain” says about indexUsage ?

    Finn


    #webMethods
    #API-Management
    #Tamino


  • 5.  RE: XQuery with >, <, gt, lt too slow

    Posted Mon January 22, 2007 10:49 AM

    Hi Finn,

    Yes, there are no posPar values higher than 9.

    The “explain” says the same about indexUsage for both XQueries. I paste here the response:

    <?xml version="1.0" encoding="windows-1252" ?>

    {?explain ?}
    for $a in input()/A
    where $a/obra=398 and $a/par=557 and $a/posPar lt 9
    return $a

    ]]>
    </xq:query>

    Thanks in advance,


    #Tamino
    #API-Management
    #webMethods


  • 6.  RE: XQuery with >, <, gt, lt too slow

    Posted Mon January 22, 2007 01:15 PM

    Hi Pau,
    May I recommend that you use the XQUERY tool which does a translation of the explain output into a more readable format :wink:
    Finn


    #API-Management
    #webMethods
    #Tamino


  • 7.  RE: XQuery with >, <, gt, lt too slow

    Posted Mon January 22, 2007 01:56 PM

    Hi Finn,

    The “Explain Query” of the XQuery tool answers this:

    "
    This query compiles successfully.

    This query will perform an index scan (details unknown).

    The analyzed query:
    {?explain?}
    for $a in input()/Locali
    where $a/obra=398 and $a/par=557 and $a/posPar = 2
    return $a
    "

    And the “Response” tab shows the same message than the Interactive Interface.

    :frowning:

    regards,


    #API-Management
    #Tamino
    #webMethods


  • 8.  RE: XQuery with >, <, gt, lt too slow

    Posted Mon January 22, 2007 07:23 PM

    Hi Pau,

    • then I’m beginning to run out of suggestions ! :frowning:

    How many hits do you get/want ?

    • Have you tried specifying a position filter to see if this show the same difference in execution time ?

    Finn

    (for $a in input()/A
    where $a/obra=398 and $a/par=557 and $a/posPar>=2
    return $a ) [position() < 10 ]


    #API-Management
    #Tamino
    #webMethods


  • 9.  RE: XQuery with >, <, gt, lt too slow

    Posted Tue January 23, 2007 01:10 PM

    Hi Finn,

    I found another XQuery which executes efficiently. I just separated the criteria into two pieces. In one hand, the “equals” comparison, and in the other hand the “less than or equals” comparison. Just like this:

    for $a in input()/A [posPar <= 9]
    where $a/obra=398 and $a/par=557
    return $a

    I don’t know why Tamino likes this one but not the other one. But it works.

    Thanks for your attention,

    Best regards.


    #Tamino
    #webMethods
    #API-Management