0

나는 MongoDB의 3 개 가지 속성에 대한 검색 MongoRepository에서 파생 된 봄 데이터 저장소로 정의 파인더가 있습니다. 세 가지 모두 단일 색인을 가지고 있습니다.봄 데이터 REST : 느린 페이지 요약

그래서 페이지에 대한 쿼리가 매우 빠른 (을 13ms)입니다
"page": { 
    "size": 20, 
    "totalElements": 2531397, 
    "totalPages": 126570, 
    "number": 5 
} 

몽고 로그 파일에서 볼 수 있듯이 :

public Page<Content> findByIdInOrAuthorUserNameInOrTagsIdIn(
    @Param("ids") Collection ids,               
    @Param("userNames") Collection userName,               
    @Param("tagIds") Collection tagIds,                
    @Param("pageable") Pageable pageable); 

문제는 하나가 2,5 미오 항목의 결과 세트를 한 속성이다 :

2017-04-10T12:50:27.562+0200 I COMMAND [conn68] command content.content command: find { find: "content", filter: { $or: [ { $or: [ { _id: { $in: [ "..." ] } }, { author.userName: { $in: [ "...", "..." ] } } ] }, { tags._id: { $in: [ "..." ] } } ] }, skip: 100, limit: 20 } planSummary: IXSCAN { _id: 1 }, IXSCAN { tags._id: 1 }, IXSCAN { author.userName: 1 } keysExamined:120 docsExamined:120 cursorExhausted:1 numYields:0 nreturned:20 reslen:21185 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 13ms 

그러나이 결과를 계산 페이지 요약 걸리는 것 같습니다 ~ 117s :

2017-04-10T12:52:24.172+0200 I COMMAND [conn68] command content.content command: count { count: "content", query: { $or: [ { $or: [ { _id: { $in: [ "..." ] } }, { author.userName: { $in: [ "...", "..." ] } } ] }, { tags._id: { $in: [ "..." ] } } ] } } planSummary: IXSCAN { _id: 1 }, IXSCAN { tags._id: 1 }, IXSCAN { author.userName: 1 } keysExamined:2531466 docsExamined:2531397 numYields:21190 reslen:44 locks:{ Global: { acquireCount: { r: 42382 } }, Database: { acquireCount: { r: 21191 } }, Collection: { acquireCount: { r: 21191 } } } protocol:op_query 116592ms 

페이지 요약을 끄거나 계산 속도를 높이는 방법이 있습니까?

+0

확실하지 않음이 작동하지만, 당신은 페이지 대신 슬라이스를 시도하는 경우 : http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/ Slice.html –

+0

그게 바로 내가 잠근 것입니다 :) 슬라이스는 Pageable 매개 변수와 결합 될 수도 있습니다. 감사합니다 –

+0

답변을 작성 했으므로 닫을 수 있으며 시스템에서 여전히 답이 없다고 생각하지 않습니다. –

답변

1

대신 사용 PageSlice. Page과 매우 유사하지만 총 요소 수가 필요하지 않습니다.