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

dbStats (데이터베이스 명령)

dbStats

The dbStats command returns storage statistics for a given database.

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

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

중요

This command has limited support in M0 and Flex clusters. For more information, see Unsupported Commands.

명령은 다음과 같은 구문을 가집니다:

db.runCommand(
{
dbStats: 1,
scale: <number>,
freeStorage: 0
}
)

이 명령은 다음 필드를 사용합니다.

필드
설명

1

선택 사항입니다. 다양한 크기의 데이터에 대한 배율 인수입니다. 크기 데이터를 바이트 단위로 반환하려면 scale 기본값은 1입니다. 바이트가 아닌 킬로바이트를 표시하려면 scale 값 1024로 지정합니다.

정수가 아닌 배율 인수를 지정하면 MongoDB는 지정된 인수의 정수 부분을 사용합니다. 예를 들어, 배율 인수를 1023.999 으로 지정하면 MongoDB는 배율 인수로 1023 을 사용합니다.

버전 4.2부터 출력에 크기 값의 크기를 조정하는 데 사용되는 scaleFactor 이 포함됩니다.

선택 사항입니다. 컬렉션에 할당된 여유 공간에 대한 정보를 반환하려면 freeStorage를 1로 설정합니다.

If the instance has a large number of collections or indexes, obtaining free space usage data may cause processing delays. To gather dbStats information without free space details, either set freeStorage to 0 or do not include the field.

mongosh에서 db.stats() 함수는 dbStats에 대한 래퍼(wrapper)를 제공합니다.

명령을 실행하는 데 필요한 시간은 데이터베이스의 총 크기에 따라 달라집니다. 명령은 모든 데이터 파일을 처리해야 하므로 명령을 실행하는 데 몇 초 정도 걸릴 수 있습니다.

After an unclean shutdown of a mongod using the Wired Tiger storage engine, count and size statistics reported by dbStats may be inaccurate.

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

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

비정상 종료 후

To run on a replica set member, dbStats operations require the member to be in PRIMARY or SECONDARY state. If the member is in another state, such as STARTUP2, the operation errors.

dbStats.db

데이터베이스의 이름입니다.

dbStats.collections

데이터베이스에 있는 컬렉션의 수입니다.

dbStats.views

데이터베이스의 뷰 수입니다.

dbStats.objects

모든 컬렉션의 데이터베이스에 있는 객체(특히, 문서)의 수입니다.

dbStats.avgObjSize

Average size of each document in bytes. This is the dataSize divided by the number of documents. The scale argument does not affect the avgObjSize value.

dbStats.dataSize

Total size of the uncompressed data held in the database. The dataSize decreases when you remove documents.

압축이 활성화된 경우 WiredTiger 스토리지 엔진을 사용하는 데이터베이스의 경우 dataSize가 storageSize보다 클 수 있습니다. 문서가 축소되면 dataSize가 감소합니다.

dbStats.storageSize

여유 공간을 포함하여 문서 저장을 위해 데이터베이스의 모든 컬렉션에 할당된 디스크 공간의 합계입니다.

The storageSize does not decrease as you remove or shrink documents. This value may be smaller than dataSize for databases using the WiredTiger storage engine with compression enabled.

storageSize does not include space allocated to indexes. See indexSize for the total index size.

dbStats.freeStorageSize

문서 저장을 위해 데이터베이스의 모든 컬렉션에 할당된 여유 공간의 합계입니다. 컬렉션에 여유 데이터베이스 저장 공간이 할당되었지만 데이터가 포함되어 있지 않습니다.

freeStorageSize does not include free space allocated to indexes. See indexFreeStorageSize for the total free index size.

To include this value in the dbStats output, set freeStorage to 1.

버전 5.3.0, 5.2.1, 및 5.0.6에서 업데이트됨

dbStats.indexes

데이터베이스에 있는 모든 컬렉션의 총 인덱스 수입니다.

dbStats.indexSize

사용 가능한 인덱스 공간을 포함하여 데이터베이스의 모든 인덱스에 할당된 디스크 공간의 합계입니다.

참고

필드 에 기본값 인덱스 만 있는 클러스터형 _ìd 컬렉션( 세컨더리 인덱스 없음)에서는 컬렉션 에 별도의 인덱스 파일 필요하지 않기 때문에 인덱스 크기가 0으로 표시됩니다.

dbStats.indexFreeStorageSize

데이터베이스의 모든 인덱스에 할당된 여유 디스크 공간의 합계입니다. 데이터베이스 저장소 여유 공간은 인덱스에 할당되지만 데이터는 포함하지 않습니다.

indexFreeStorageSize does not include free space allocated to document storage. See freeStorageSize for the total free document storage size.

indexFreeStorageSize 진행 중인 인덱스 빌드가 포함되지 않습니다.

To include this value in the dbStats output, set freeStorage to 1.

버전 7.0, 6.3.2, 6.0.7, 5.3.0, 5.2.1, 5.0.19 및 5.0.6에서 업데이트되었습니다.

dbStats.totalSize

Sum of the disk space allocated for both documents and indexes in all collections in the database. Includes used and free storage space. This is the sum of storageSize and indexSize.

dbStats.totalFreeStorageSize

Sum of the free storage space allocated for both documents and indexes in all collections in the database. This is the sum of freeStorageSize and indexFreeStorageSize.

To include this value in the dbStats output, set freeStorage to 1.

버전 5.3.0, 5.2.1, 및 5.0.6에서 업데이트되었습니다,

dbStats.scaleFactor

scale 명령에 사용되는 값입니다.

정수가 아닌 배율 인수를 지정한 경우 MongoDB는 지정된 인수의 정수 부분을 사용합니다. 예를 들어, 배율 인수를 1023.999로 지정하면 MongoDB는 배율 인수로 1023을 사용합니다.

dbStats.fsUsedSize

MongoDB가 데이터를 저장하는 파일 시스템에서 사용 중인 모든 디스크 공간의 총 크기입니다.

dbStats.fsTotalSize

MongoDB가 데이터를 저장하는 파일시스템의 모든 디스크 용량의 총 크기입니다.

The following examples demonstrate dbStats usage.

반환되는 데이터를 단일 필드로 제한하려면 dbStats 명령에 필드 이름을 추가합니다. 이 예시에서는 indexSize 값을 반환합니다.

db.runCommand( { dbStats: 1 } ).indexSize

To view free storage usage, set freeStorage to 1.

db.runCommand( { dbStats: 1, scale: 1024, freeStorage: 1 } )

출력 예시:

{
db: 'test',
collections: 2,
views: 0,
objects: 1689,
avgObjSize: 52.56542332741267,
dataSize: 86.7021484375,
storageSize: 100,
freeStorageSize: 32,
indexes: 2,
indexSize: 116,
indexFreeStorageSize: 36,
totalSize: 216,
totalFreeStorageSize: 68,
scaleFactor: 1024,
fsUsedSize: 60155820,
fsTotalSize: 61255492,
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1646085664, i: 1 }),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1646085664, i: 1 })
}

freeStorage 공간 필드를 사용하면 강조 표시된 메트릭을 수집하고 표시할 수 있습니다.

scale 필드는 표시되는 값을 킬로바이트로 설정합니다.

이 페이지 평가하기