0 Replies Latest reply: Oct 28, 2011 12:33 PM by 896739 RSS

    XQuery sorting issue

    896739
      Hi,
      Right now I am in a big trouble. I am new in XQuery, but right now I'm in a project using Xquery using PHP and XSLT..

      In our project we have large no. data (its a property listing site) and I'm storing that data to Berkeley DB (XML DB). The problem is when I am searching for a property its taking too much time for getting the result. The ORDER BY is creating the problem(Query 1).. with out sorting its working fine(Query 2). But for my project sorting is needed and its very impotent. So kindly please check my query(Query1) and please give me a solution as soon as possible. Following are the query:

      Query1:

      let $properties := (
      for $property in collection('bdb/properties.dbxml')/properties/property
      [( sale_price >=60000 and sale_price <=500000 ) and ( building_square_footage >=300 and building_square_footage <=3000 ) and ( bedrooms >=2 and bedrooms <=6 )]
      order by
      contains($property/mls_agent_id/text(), '505199') descending,
      matches($property/mls_office_id/text(), '^CBRR') ascending,
      $property/sale_price/number() descending
      return $property
      )

      let $properties := subsequence($properties,10,10) return <properties>{$properties}</properties>

      Query 2:

      let $properties := (
      for $property in subsequence (
      collection('bdb/properties.dbxml')/properties/property
      [( sale_price >=60000 and sale_price <=500000 ) and ( building_square_footage >=300 and building_square_footage <=3000 ) and ( bedrooms >=2 and bedrooms <=6 )]
      , 1, 10)
      )
      descending return $property
      ) return <properties>{$properties}</properties>


      Thank you,

      Vijesh

      Edited by: 893736 on Oct 28, 2011 10:28 AM

      Edited by: 893736 on Oct 28, 2011 10:33 AM