我读到,Mongoose将只开一个最长的链接,没有办法改变这一联系。
这是否意味着缓慢的中点会使得随后的所有询问都等待?
我知道一切。 j 不是锁定的,但我很想知道,缓慢的询问是否会拖延执行所有随后的询问。 是否有办法改变这种状况。
我读到,Mongoose将只开一个最长的链接,没有办法改变这一联系。
这是否意味着缓慢的中点会使得随后的所有询问都等待?
我知道一切。 j 不是锁定的,但我很想知道,缓慢的询问是否会拖延执行所有随后的询问。 是否有办法改变这种状况。
只有当你使用缺省方法时,才会使用一条连接。 为了解决这一问题,你可以建立多种联系,然后将同一图示的模型与这一联系联系起来。
与此类似:
var conn = mongoose.createConnection( mongodb://localhost/test );
var conn2 = mongoose.createConnection( mongodb://localhost/test );
var model1 = conn.model( Model , Schema);
var model2 = conn2.model( Model , Schema);
model1.find({long query}, function() {
console.log("this will print out last");
});
model2.find({short query}, function() {
console.log("this will print out first");
});
希望会有所帮助。
Update Hey, that does work. Updating from the comments, you can create a connection pool using createConnection. It lets you do multiple queries from the same model concurrently:
var conn = mongoose.createConnection( mongodb://localhost/test , {server:{poolSize:2}});
var model = conn.model( Model , Schema);
model.find({long query}, function() {
console.log("this will print out last");
});
model.find({short query}, function() {
console.log("this will print out first");
});
Update 2 -- Dec 2012
This answer may be slightly outdated now--I noticed I ve been continuing to get upvotes, so I thought I would update it. The mongodb-native driver that mongoose wraps now has a default connection pool size of 5, so you probably don t need to explicitly specify it in mongoose.
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one ...
Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0
What re the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { ...
I ve been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I m considering switching to a NoSQL datastore with an ...
I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...
I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...
My application creates pieces of data that, in xml, would look like this: <resource url="someurl"> <term> <name>somename</name> <frequency>somenumber</...