mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Loading a DB document takes more than 2 mins

Open mshanmu8 opened this issue 7 years ago • 1 comments

I have a KOA (instead) app to load the some ENV variables from DB and use them in App, everything was working fine but suddenly loading a single document takes more than 2 mins which is damn frustrating. The db has only one document.

I tried to load data from other app and it loads data fine.

I have a static method, to create conn and load config,

public static createConn() { mongoose.connect(MongoEnv.MONGO_URL, { user: MongoEnv.MONGO_USER, pass: MongoEnv.MONGO_PASSWORD, useNewUrlParser: true, useCreateIndex: true, autoReconnect: true, connectTimeoutMS: 180000, socketTimeoutMS: 180000 }); }

public static async loadEnvVariables() { const start = Date.now(); this.config = await Config.findById({ _id: 'nestor-ui-config' }); const millis = Date.now() - start; console.log(load mongo config took ${millis} mseces); console.log(this.config); }

and I call these two methods from serve.ts. here are the package versions I use, "mongoose": "^5.5.8", "koa": "^2.7.0"

I am not sure if this is an issue with mongoose, if any help will be mush appreciated. Thanks.

mshanmu8 avatar May 16 '19 05:05 mshanmu8

Are you executing other queries at the same time? Sounds like a slow train problem.

vkarpov15 avatar May 18 '19 11:05 vkarpov15