diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2017-07-24 15:13:42 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2017-07-24 15:15:41 -0400 |
commit | 84a658596bc62107539a07556b9c066af2fec683 (patch) | |
tree | c31ad008c63b803bed2db473e9bd96c126ad6740 | |
parent | 01a38984d5c7b134b177d1b78023ed779c8b1631 (diff) | |
download | mongo-84a658596bc62107539a07556b9c066af2fec683.tar.gz |
SERVER-29817 Use hinted insert when building CollectionMetadata for performance.
-rw-r--r-- | src/mongo/db/s/collection_metadata.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_state.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp index cc650362677..734e55cfeba 100644 --- a/src/mongo/db/s/collection_metadata.cpp +++ b/src/mongo/db/s/collection_metadata.cpp @@ -84,7 +84,8 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern, continue; } - _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace_hint( + _rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED())); min = currMin; max = currMax; @@ -93,7 +94,7 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern, invariant(!min.isEmpty()); invariant(!max.isEmpty()); - _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace_hint(_rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED())); } CollectionMetadata::~CollectionMetadata() = default; diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp index a0f0c5b1a4f..e264c82b57f 100644 --- a/src/mongo/db/s/sharding_state.cpp +++ b/src/mongo/db/s/sharding_state.cpp @@ -645,8 +645,9 @@ ChunkVersion ShardingState::_refreshMetadata(OperationContext* txn, const Namesp if (chunk->getShardId() != shardId) continue; - shardChunksMap.emplace(chunk->getMin(), - CachedChunkInfo(chunk->getMax(), chunk->getLastmod())); + shardChunksMap.emplace_hint(shardChunksMap.end(), + chunk->getMin(), + CachedChunkInfo(chunk->getMax(), chunk->getLastmod())); } return stdx::make_unique<CollectionMetadata>(cm->getShardKeyPattern().toBSON(), |