balderdashy / balderdashy/sails

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

Open
#4,608 12 comments 2 reactions 0 assignees View on GitHub
helpful info or workaround mongo orm performance
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**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

Contributor guide

Open the contributing guide

Research direction

Start with the reported Waterline find examples and the MongoDB command showing type: /^type1$/i, then reproduce the query and inspect how sails-mongo generates its filter. Done means the equality forms no longer become regex filters and the resulting MongoDB query shows the expected performance behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.