This discussion is archived
1 Reply Latest reply: Jul 25, 2011 11:25 PM by 655560 RSS

Index not used for order by/subsequence

761557 Newbie
Currently Being Moderated

I can't seem to get DBXML to efficiently return an ordered subsequence (so that a web page can do pagination in order). I have 100,000 entries in my test container and the following indexes:
Index: unique-node-metadata-equality-string for node {}:name
Index: edge-element-equality-dateTime for node {}:when
Index: edge-element-equality-double for node {}:whenNumber
queryPlan "
for $x in (collection('test.dbxml')/root)
    order by $x/whenNumber
    return subsequence($x, 1, 10)
Gives me a plan with a sequential scan in it:
    <OrderByTuple direction="ascending" empty="least" stable="false" collation="">
      <ForTuple uri="" name="x">
          <StepQP axis="child" name="root" nodeType="element">
            <SequentialScanQP container="test.dbxml" nodeType="document"/>
        <PromoteUntyped uri="" name="string">
              <StepQP axis="child" name="whenNumber" nodeType="element">
                <VariableQP name="x"/>
        <SequenceType type="item()?"/>
    <Function name="{}:subsequence">
        <VariableQP name="x"/>
      <NumericLiteral value="1.0E0" typeuri="" typename="double"/>
      <NumericLiteral value="1.0E1" typeuri="" typename="double"/>
The index is used correctly if I do a conditional query as I woudl expect


  • Correct Answers - 10 points
  • Helpful Answers - 5 points