sails-mongo: In clause FIND, the equality is replaced by a regex So decrease in performance

Created on 17 Jan 2019  路  12Comments  路  Source: balderdashy/sails

Waterline version: 0.13.x
Node version: 8.9.1
NPM version: 6.5.0
Operating system: ubuntu 16.04



For examples :
models.Task.find({type:'type1'}) or models models.Task.find({type:{$eq:'type1'} })

Queries in Mongodb :
command task command: find { find: "task", filter: { type: /^type1$/i }, projection: {} }
planSummary: IXSCAN { type: 1 } keysExamined:1612853 docsExamined:44 cursorExhausted:1 numYields:12615 nreturned:44 reslen:34028 locks:{ Global: { acquireCount: { r: 25232 } }, MMAPV1Journal: { acquireCount: { r: 12616 } }, Database: { acquireCount: { r: 12616 } }, Collection: { acquireCount: { R: 12616 } } }
protocol:op_query 3669ms

This request runs for more than 3 seconds. Equality is replaced by a regex. Why ????
The time is same with Robomongo.

I changed the regex expression by an equality in Robomongo.
The request lasted 300ms, so 10 times less

helpful info or workaround mongo orm performance

Most helpful comment

@johnabrams7 I don't think it's necessary, it is only happening for legacy versions of sails and fixing it would break the caseSensitive "feature". It can solved easily by setting caseSensitive to true in config/connections.js, e.g.

localMongoServer: {
      adapter: 'sails-mongo',
      host: '192.168.2.121',
      port: 27017,
      wlNext:{
        caseSensitive: true,
      },
      database: 'wra' //optional
},

(see https://github.com/balderdashy/sails/issues/4752#issuecomment-283021600 for original post)

All 12 comments

Hi @TottiFr! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.

Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]

ok, fixed!

Sorry to be a hassle, but it looks like your issue is still missing some required info. Please double-check your initial comment and try again.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]

ok, fixed!

Sorry to be a hassle, but it looks like your issue is still missing some required info. Please double-check your initial comment and try again.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]

ok, fixed!

@TottiFr Thanks for posting, we'll take a look as soon as possible.


For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.

@TottiFr Thanks for bringing this up. I'm down to look at a pull request that adds this to sails-mongo (cc @luislobo)

Hey @TottiFr , we're moving all the Waterline issues to the main Sails repo support (balderdashy/sails). Thanks for all the efforts so far and feel free to update this as needed. Pull requests welcome!

I agree with @mikermcneil - feel free to submit a pull request with these changes for sails-mongo 馃憤

@Marigold Appreciate the follow-up. Mike is open to look at a sails-mongo PR for this (be sure to cc @luislobo).

@johnabrams7 I don't think it's necessary, it is only happening for legacy versions of sails and fixing it would break the caseSensitive "feature". It can solved easily by setting caseSensitive to true in config/connections.js, e.g.

localMongoServer: {
      adapter: 'sails-mongo',
      host: '192.168.2.121',
      port: 27017,
      wlNext:{
        caseSensitive: true,
      },
      database: 'wra' //optional
},

(see https://github.com/balderdashy/sails/issues/4752#issuecomment-283021600 for original post)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

randallmeeker picture randallmeeker  路  4Comments

mahfuzur picture mahfuzur  路  3Comments

victory-deployment picture victory-deployment  路  4Comments

Noitidart picture Noitidart  路  4Comments

pawankorotane picture pawankorotane  路  3Comments