Tested Aqua Data Studio Aqua Data Studio 14.0.0-rc-13 Build #: 33892 on Ubuntu 12.04( Mongo DB 2.4.3)
I have other results than in ticket 9058.
I make next test and performance is slow. Also COUNT( ) works faster through aggregation frame works faster then .count() with $exists and $ne:null.
Make next steps:
1. Generate new collection with 5M records:
setVerboseShell(false)
for ( i = 0; i < 5000000; i++ ) { db.largegen.save( { _id: i, ts: new Date() } )};
2. Measure performance in ADS MongoShell
a) using "$exists" : true, $not:{$type:10}
var before = new Date()
db.largegen.find({$and:[ { "_id" : { "$exists" : true, $not:{$type:10} }}]},{_id:1}).count()
var after = new Date()
Rtime=after- before
Rtime=after- before
--14491
b) Using "$exists" : true, $not:{$type:10} } in aggregation framework:
var before = new Date()
db.largegen.aggregate({$match:{$and:[ { "_id" : { "$exists" : true, $not:{$type:10} } }]}}, { "$group" : { "_id" : 0, "cnt" : { "$sum" : 1 } } },{ "$project" : { "_id" : 0, "cnt" : 1 } } )
var after = new Date()
Rtime=after- before
Rtime=after- before
--9164
c) Currently working regular count( ) with "$exists" : true, "$ne":null
var before = new Date()
db.largegen.find({$and:[ { "_id" : { "$exists" : true, "$ne":null }}]},{_id:1}).count()
var after = new Date()
Rtime=after- before
Rtime=after- before
--16645
3. See also performance in ADS QA
select count(_id),min(ts) from largegen
--13 sec
go
select count(ts) from largegen
--7 sec
go
select count(_id) from largegen
--16 sec
go
select count(_id),count(_id) from largegen
--10sec
go