AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

db. 컬렉션.estimatedDocumentCount() (mongosh 메서드)

드라이버가 포함된 MongoDB

This page documents a mongosh method. To see the equivalent method in a MongoDB driver, see the corresponding page for your programming language:
db.collection.estimatedDocumentCount(options)

컬렉션 또는 뷰에 있는 모든 문서의 개수를 반환합니다.

db.collection.estimatedDocumentCount( <options> )
Parameter
유형
설명

옵션

문서

선택 사항입니다. 카운트 동작에 영향을 주는 예비 옵션입니다.

options 문서에는 다음을 포함할 수 있습니다.

필드
유형
설명

maxTimeMS

integer

선택 사항. 카운트 실행을 허용하는 최대 시간입니다.

이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

참고

이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.

db.collection.estimatedDocumentCount() 는 쿼리 필터 대신 메타데이터를 사용하여 collection의 개수를 반환합니다.

보기:

  • 메타데이터가 없습니다.

  • 문서 수는 뷰 정의에서 집계 파이프라인을 실행하여 계산됩니다.

  • 문서 수에 대한 빠른 예상치는 없습니다.

샤딩된 클러스터에서는 결과 개수가 고아 문서를 제대로 필터링하지 못합니다.

이 섹션은 collection에만 적용됩니다.

비정상 종료 후에는 개수가 부정확할 수 있습니다.

After an unclean shutdown of a mongod using the Wired Tiger storage engine, count statistics reported by db.collection.estimatedDocumentCount() may be inaccurate.

편차의 정도는 마지막 체크포인트와 비정상 종료 사이에 수행된 삽입, 업데이트 또는 삭제 작업의 수에 따라 달라집니다. 체크포인트는 보통 60초마다 발생합니다. 그러나mongod 기본값이 아닌 --syncdelay 설정으로 실행되는 인스턴스는 체크포인트가 다소 빈번하게 발생할 수 있습니다.

mongod의 각 컬렉션에서 validate를 실행하여 비정상 종료 후 통계를 복원합니다.

비정상 종료 후

If the client that issued db.collection.estimatedDocumentCount() disconnects before the operation completes, MongoDB marks db.collection.estimatedDocumentCount() for termination using killOp.

When you use db.collection.estimatedDocumentCount() in a transaction, the resulting count will not filter out any uncommitted multi-document transactions.

이 페이지의 예시에서는 sample_mflix 샘플 데이터 세트의 데이터를 사용합니다. 이 데이터 세트를 자체 관리형 MongoDB 배포서버에 로드하는 방법에 대한 자세한 내용은 샘플 데이터 세트 로드를 참조하세요. 샘플 데이터베이스를 수정한 경우 이 페이지의 예시를 실행 하려면 데이터베이스를 제거하고 다시 만들어야 할 수 있습니다.

The following example uses db.collection.estimatedDocumentCount() to retrieve the count of all documents in the movies collection:

db.movies.estimatedDocumentCount({})
21349
이 페이지 평가하기

이 페이지의 내용