mergeAllChunksOnShard
정의
mergeAllChunksOnShard
mergeAllChunksOnShard
finds and merges all mergeable chunks that a shard owns for a given collection.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
중요
이 명령은 서버리스 인스턴스에서는 지원되지 않습니다. 자세한 내용은 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.adminCommand( { mergeAllChunksOnShard: <name of the collection>, shard: <name of the shard>, maxNumberOfChunksToMerge: <maximum number of chunks to merge> /* optional */ } )
명령 필드
이 명령은 다음 필드를 사용합니다.
필드 | 유형 | 필요성 | 설명 |
---|---|---|---|
| 문자열 | 필수 사항 | 컬렉션의 이름입니다. |
| 문자열 | 필수 사항 | Name of the shard. |
| integer | 옵션 | Maximum number of chunks to merge. |
행동
mergeAllChunksOnShard
finds and merges all mergeable chunks for a
collection on the same shard. Two or more contiguous chunks in the same
collection are mergeable when they meet all of these conditions:
They are owned by the same shard.
They are not jumbo chunks.
jumbo
chunks are not mergeable because they cannot participate in migrations.Their history can be purged safely, without breaking transactions and snapshot reads:
The last migration involving the chunk happened at least as many seconds ago as the value of
minSnapshotHistoryWindowInSeconds
.The last migration involving the chunk happened at least as many seconds ago as the value of
transactionLifetimeLimitSeconds
.
예시
This example assumes that history is empty for all chunks and all chunks are non-jumbo. Since both conditions are true, all contiguous intervals on the same shard are mergeable.
설정
These chunks belong to a collection named coll
with shard key x
.
There are nine chunks in total.
Chunk ID | Min | Max | 샤드 |
---|---|---|---|
A |
|
| Shard0 |
B |
|
| Shard0 |
C |
|
| Shard0 |
D |
|
| Shard0 |
E |
|
| Shard1 |
F |
|
| Shard1 |
G |
|
| Shard0 |
H |
|
| Shard0 |
I |
|
| Shard1 |
단계
결과
After these commands have completed, the contiguous chunks have been merged. There are four total chunks instead of the original nine.
Chunk ID | Min | Max | 샤드 |
---|---|---|---|
A-B-C-D |
|
| Shard0 |
E-F |
|
| Shard1 |
G-H |
|
| Shard0 |
I |
|
| Shard1 |