1

we've meet with really weird problem. Our simple queries to MongoDB takes really long time to return any document. Database is well indexed. We've made few tests and here they are:

File.find({sharename: '7iPJUtP2'}, function(err, shares){
      console.log(err,shares);
});

console.log fires after 60s.

Then we use .native() method:

File.native(function(err, collection){
      collection.find({sharename: '7iPJUtP2'}, {})
         .toArray(function (err, results) {
            console.log(err,results);
         });
});

Here console.log fires in 103ms.

The stack we use is:

  • sails: 0.11.0
  • sails-mongo: 0.11.5
  • MongoDB: 2.0.1
  • Waterline: 0.10.28

Can someone help with this issue?

Update

File.find({sharename: '1'}) executes in 50ms.

File.find({sharename: 'a'}) executes in 18000ms.

Documents are identical except of sharename field.

Roman Paraschak
  • 175
  • 1
  • 9

1 Answers1

0

Finally i found the problem. Mongo query builder makes query to look like .find({ sharename: /^qwerty$/i }}) instaed of .find({ sharename: 'qwerty' }}). It works great in latest MongoDB versions, but for mongo 2.0.1 it doesn't use indexes.

I had to fix this issue directly in sails-mongo package. I have create fork, so if anyone will meet this problem you can use it. https://github.com/rparaschak/sails-mongo.git

Roman Paraschak
  • 175
  • 1
  • 9