A member of our team happened to notice that the performance of a simple find() operation via mongoose was performing much more slowly than via native mongodb-native. His test case retrieved about 8000 records via a single indexed key (an ObjectID). The operation took about 600ms with mongodb-native but over 3000ms with mongoose. I repeated the test with mongoose 3.0 (alpha) and the time is down to about 2000ms, which is a significant improvement but still much slower than native.
I haven't seen much discussion of mongoose's real world performance. I was surprised by this result. This is on a query so we shouldn't be seeing validation overhead. What else is going on?
In trying to isolate the overhead, I tried retrieving only the _id. The performance did improve (in both cases) but mongoose still took 3x as long.
The query looks like this:
my_model.find({
user_id: mongoose.Types.ObjectId(user_id),
}, function (err, events) { ...
The mongodb equivalent is:
my_connection.collection('event', function (err, eventCollection) {
eventCollection.find({
user_id : mongodb.ObjectID(user_id),
}).toArray(function (err, events) { ...
Is this expected? Any tips on avoiding this extra overhead?
--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
That sounds like it might be a little too lean. For reading, I'd still want getters, at least. Maybe methods and defaults too. That wouldn't introduce much overhead, at least until the getters actually get used.
Is there a way to turn "lean" to always-on on for one specific model, rather than per-find?
If I only use basic functionality in a particular Schema, will the overhead be proportional to the functionality I use, or is there a fixed overhead that is incurred for wrapping? In other words, would a find with a schema with only basic functionality be as fast as a "lean" version?
I assume it is impossible to have 2 schemas for the same collection, and switch between them depending upon what functionality I want...
I'm assuming an application with lots of configuration and UI objects for which Mongoose is very helpful, and then maybe one or two high-bandwidth underlying objects, which I'm willing to carefully craft for performance.