[MongoDB] Query Plan 읽기

기훈·2024년 4월 2일

MongoDB

목록 보기
12/28

cursor.explain() 함수를 통해 실행 계획을 출력할 수 있다.

  • explain(): 기본적인 queryPlannder 모드
  • explain('executionStats'): queryPlannder의 모든 항목과 winning plan의 세부 정보를 보여준다
  • explain('allPlansExecution'): 선택되지 않은 실행계획까지 출력 해준다.
  1. explain()

  2. explain('executionStats')

    nReturned: 반환된 도큐먼트 수
    executionTimeMillis: 쿼리 실행 시간
    totalKEysExamined: 인덱스 조회한 수
    totalDocsExamined: 결과 반환까지 조회한 총 도큐먼트 수
    works: 쿼리실행의 발생한 작업단위를 쪼개서 얼마나 많은 작업들을 진행하는지 보여줌

  3. explain('allPlansExecution')

    몽고디비는 모든 실행계획을 실행한 후 최적의 계획을 채택한다.

0개의 댓글