2011-11-01 10 views
1

私たちのプロジェクトでは、データ(そのプロパティリストサイト)とそのデータをBarkeley DB(XML DB)に保存しています。問題は、プロパティを探しているときに最初の10個のプロパティをすばやくリストする(100%の速度)ことです。それから私は2dnに行きます、第3ページは同じ速度で働いています。しかし、もし私が10位(30%のスピード)または100位または1500位(15%のスピード)になると、非常にゆっくりと作業しています。 XQueryの選択クエリが適切な速度で機能していません

は私のクエリは:

let $property_ids:= 
(
    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) and (mls_agent_id = '505199') ] 
    order by $property/sale_price/number() descending 
    return $property/@property_id, 

    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) and (starts-with(mls_office_id, 'CBRR') and not(mls_agent_id = '505199')) ] 
    order by $property/sale_price/number() descending 
    return $property/@property_id, 

    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) and not(starts-with(mls_office_id, 'CBRR')) ] 
    order by $property/sale_price/number() descending 
    return $property/@property_id 
) 
return <properties>{ 
    for $id in subsequence($property_ids, 1, 10) return 
     collection('bdb/properties.dbxml')/properties/property[@property_id = $id] 
}</properties> 

そして、いくつかの回のクエリが私のページでフィルタオプションに基づいて、次の方法のように変更されます(のみSALE_PRICEフィールドでソート意味):

let $property_ids:= 
    (
     for $property in collection('bdb/properties.dbxml')/properties/property 
     order by $property/sale_price/number() descending 
     return $property/@property_id 
    ) 
    return <properties>{ 
     for $id in subsequence($property_ids, 1, 10) return 
      collection('bdb/properties.dbxml')/properties/property[@property_id = $id] 
    }</properties> 

最初のページからそのパフォーマンスは非常に遅い(15%)。

あなたは私のクエリをチェックし、問題を解決するために私を助けてもらえ...

は、あなたがあなたのクエリを最適化する機会を十分に問い合わせプランナを与えていない、 Vijesh

答えて

0

、ありがとうございました。

idsの全体集合をロードしてから、それらの部分列を使用していくつかの要素を要求する代わりに、FLWOR式を使用して要素を取得し、要素のサブシーケンスを直接取得してみてください。

3つの連結結果セットではなく、1つのFLWORにどのように押しつぶされて、クエリプランナで助けになるかについても、サブシーケンスを実行する前に、多くのことを考える必要があります。あなたのフィルタリングの必要性を考えれば、これが不可能な理由はありません。

関連する問題