Simple MongoDB query takes over 30 seconds to execute
See original GitHub issueBug description
I have GoogleOAuth authentication through Passport in my Express server, and I run the .upsert()
function to check if a user exists, otherwise I create one. However it appears this query is taking upwards of 30 seconds, meaning the user is stuck on the OAuth consent screen for about that long waiting to be logged in. It seems this is happening on most queries I make, however I’ve only thoroughly tested with this scenario.
How to reproduce
- Set up basic auth template with passport google oauth or copy from a demo repo I made and adjust to use Prisma accordingly.
- Navigate to the login route which will eventually execute the
upsert()
function - Wait…
Prisma information
Schema file
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model User {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
googleId String @unique
displayName String
avatarUrl String
role String @default("free")
}
// query looks like this, however I've tried making a few adjustments with no success
const user = await prisma.user.upsert({
where: {
googleId: profile.id,
},
update: {},
create: {
googleId: profile.id,
displayName: profile.displayName,
avatarUrl: profile.photos[0].value,
},
});
Environment & setup
- OS: Windows 11
- Database: MongoDB (Atlas)
- Node.js version: 16.13.1
Prisma Version
3.7.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Text search with mongodb taking more than 30 seconds
I am using this simple query. When I use it without sort it runs right away but when I use sort it takes...
Read more >MongoDB query with 300k documents takes more than 30 ...
MongoDB query with 300k documents takes more than 30 seconds ; 2. try to not to fetch all the data at once, use...
Read more >Handling Slow Queries In MongoDB Pt. 1 - Rockset
We can also use the following command to list all the operations taking longer than a certain amount of time (in this case,...
Read more >Let's .explain() MongoDB Performance | Twitch Live Coding
Query performance can either be a constant headache or the unsung hero of any application. A well-tuned database will save you time, ...
Read more >Why MySQL Could Be Slow With Large Tables? - Percona
The table contains 36 million rows (Data size 5GB, Index size 4GB). I run the following query, which takes 93 seconds ! SELECT...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can confirm, the cluster was causing the problem. Thanks for the support in finding out the issue here!
Logs:
14:09:29 GMT-0500 (Eastern Standard Time) - 14:10:00 GMT-0500 (Eastern Standard Time)
I’ll shoot over the connection string shortly!