2010-08-24 07:25:45 +02:00
|
|
|
|
|
|
|
t = db.datasize3;
|
2016-02-04 18:29:39 +01:00
|
|
|
t.drop();
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
function run(options) {
|
2016-05-28 23:55:12 +02:00
|
|
|
var c = {dataSize: "test.datasize3"};
|
2016-03-09 18:17:50 +01:00
|
|
|
if (options)
|
|
|
|
Object.extend(c, options);
|
|
|
|
return db.runCommand(c);
|
2010-08-24 07:25:45 +02:00
|
|
|
}
|
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
t.insert({x: 1});
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-02-04 18:29:39 +01:00
|
|
|
a = run();
|
2016-03-09 18:17:50 +01:00
|
|
|
b = run({estimate: true});
|
|
|
|
printjson(t.stats());
|
|
|
|
assert.eq(a.size, b.size);
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
t.ensureIndex({x: 1});
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
for (i = 2; i < 100; i++)
|
|
|
|
t.insert({x: i});
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
a = run({min: {x: 20}, max: {x: 50}}).size;
|
|
|
|
b = run({min: {x: 20}, max: {x: 50}, estimate: true}).size;
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
ratio = Math.min(a, b) / Math.max(a, b);
|
2010-08-24 07:25:45 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
assert.lt(0.97, ratio, "sizes not equal a: " + a + " b: " + b);
|