Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:08:32+00:00 2026-06-01T14:08:32+00:00

I read that Mongoose will only open one connection at maximum per collection, and

  • 0

I read that Mongoose will only open one connection at maximum per collection, and there’s no option to change this.

Does this mean that a slow mongo query will make all subsequent queries wait?

I know everything in node.js is non-blocking, but I’m wondering whether a slow query will delay the execution of all subsequent queries. And whether there is a way to change this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:08:33+00:00Added an answer on June 1, 2026 at 2:08 pm

    It does only use one connection, if you use the default method where you do mongoose.connect(). To get around this, you can create multiple connections, and then tie a model pointing to the same schema to that connection.

    Like so:

    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");
    });
    

    Hope that helps.

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read that C2DM uses port 5228 for connection. Is there a ping address
I read that .NET uses connection pooling. For example, if I instantiate a bunch
I´ve read that it´s possible to share sockets between processes. Is this also possible
I read that because of the dequeueReusableCellWithIdentifier method grabbing an oldCell if there is
I read that one can use char for small integers. However, when I try,
I read that one can support query by humming by using MIDI files. Can
I read that Lucene has an internal query language where one specifies : and
I read that this could improve the performance of XCode 4 which is running
I read that int c; while(c = getchar() != EOF) { putchar(c); } will
I read that a page which runs under an https connection cannot share an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.