Docs Menu

mergeAllChunksOnShard

mergeAllChunksOnShard

mergeAllChunksOnShard finds and merges all mergeable chunks that a shard owns for a given collection.

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

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

중요

이 명령은 서버리스 인스턴스에서는 지원되지 않습니다. 자세한 내용은 지원되지 않는 명령을 참조하세요.

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

db.adminCommand(
{
mergeAllChunksOnShard: <name of the collection>,
shard: <name of the shard>,
maxNumberOfChunksToMerge: <maximum number of chunks to merge> /* optional */
}
)

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

필드
유형
필요성
설명

mergeAllChunksOnShard

문자열

필수 사항

컬렉션의 이름입니다.

shard

문자열

필수 사항

Name of the shard.

maxNumberOfChunksToMerge

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:

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

x: 0

x: 10

Shard0

B

x: 10

x: 20

Shard0

C

x: 20

x: 30

Shard0

D

x: 30

x: 40

Shard0

E

x: 40

x: 50

Shard1

F

x: 50

x: 60

Shard1

G

x: 60

x: 70

Shard0

H

x: 70

x: 80

Shard0

I

x: 80

x: 90

Shard1

1
db.adminCommand( { mergeAllChunksOnShard: "db.coll", shard: "Shard0" } )

This command merges the contiguous sequences of chunks:

  • A-B-C-D

  • G-H

2
db.adminCommand( { mergeAllChunksOnShard: "db.coll", shard: "Shard1" } )

This command merges the contiguous sequences of chunks E-F.

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

x: 0

x: 40

Shard0

E-F

x: 40

x: 60

Shard1

G-H

x: 60

x: 80

Shard0

I

x: 80

x: 90

Shard1