From 2af7fa477c6a0764e0af9def5ed7a2fdd0cdfe47 Mon Sep 17 00:00:00 2001 From: Alberto Lerner Date: Mon, 23 Aug 2010 20:00:14 -0400 Subject: [PATCH] SERVER-1545 Leave new chunks half-full instead of at 90%. --- s/d_split.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/s/d_split.cpp b/s/d_split.cpp index 1902596f049..a3b0cd18c0a 100644 --- a/s/d_split.cpp +++ b/s/d_split.cpp @@ -155,20 +155,17 @@ namespace mongo { } // We'll use the average object size and number of object to find approximately how many keys - // each chunk should have. We'll split a little smaller than the specificied by 'maxSize' - // assuming a recently sharded collectio is still going to grow. - + // each chunk should have. We'll split at half the maxChunkSize. const long long recCount = d->nrecords; long long keyCount = 0; if (( dataSize > 0 ) && ( recCount > 0 )){ const long long avgRecSize = dataSize / recCount; - keyCount = 90 * maxChunkSize / (100 * avgRecSize); + keyCount = maxChunkSize / (2 * avgRecSize); } // We traverse the index and add the keyCount-th key to the result vector. If that key // appeared in the vector before, we omit it. The assumption here is that all the // instances of a key value live in the same chunk. - Timer timer; long long currCount = 0; vector splitKeys;