2011-11-01 2 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

당신은 당신의 쿼리를 최적화 할 수있는 기회의 충분한 쿼리 계획을 포기하지 않을거야,

감사합니다 ... 내 쿼리를 확인하고 나에게 문제를 해결하는 데 도움이 시겠어요.

전체 집합을로드 한 다음 하위 시퀀스를 사용하여 몇 가지 요소를 요청하는 대신 FLWOR 식을 사용하여 요소를 검색하고 요소의 하위 시퀀스를 직접 가져 오십시오.

또한 쿼리 플래너가 도움을주기를 원한다면 하위 시퀀스를 수행하기 전에 세 개의 연결된 결과 집합 대신 단일 FLWOR로 채워지는 방법에 대해 많은 생각을해야합니다. 필터링 요구 사항을 감안할 때 이것이 가능하지 않은 이유는 없습니다.

관련 문제