Why query on empty collection is taking longer than 5 sec

A query on collection is taking longer than 5 seconds at time, and it is having no data

query: { name: “test123”, insertTime: { $gte: new Date(1598767200000) } } } planSummary: IXSCAN { insertTime: -1.0 } keyUpdates:0 writeConflicts:0 numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } 889ms

Thanks
Santhosh

We need a little more information. Where is the server running, locally or remotely? Are there other programs imposing a load?

Whenever you see a performance problem the first step is the run the query in the shell with an explain plan e.g.

$ db.collection.find{{}).explain("executionStats")

This can often tell us where the bottleneck is.

2 Likes