matic
03/24/2022, 7:25 PMclient.challengeAttempt.findUnique({
where: { challengeId_userId: { challengeId: 'ac', userId: 'dc' } },
})
model ChallengeAttempt {
id String @id @default(cuid())
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId String
user User @relation(fields: [userId], references: [id])
userId String
@@unique([challengeId, userId])
}
My understanding is that querying a unique field should be almost instant while in our case the logs show that every day some queries need a couple of seconds (range from 200ms to 15s) to finish. We’ve also investigated that the payload is as small as it can be (and it’s small).
We are currently processing at most three concurrent requests every second and the CPU/memory of our server barely scratches the potential. DB, on the other hand, is quite bad and reaches the spike every day even though we have 2GB of RAM.
Apart from that, we are getting “Timeout fetching a new connection from the pool” even though the pool limit is 84 connections. (strangely, the logs show that there’s no active connection at all times)
I’ve also seen this review (https://github.com/edgedb/imdbench) and wanted to ask:
1. Is 2GB of RAM for a db for an app of our size too little?
2. Is this a common problem?
3. How do you cope with low performance?
At this point, we are considering switching to something else and help/feedback would be greatly appreciated 🙂Chris Tsongas
03/24/2022, 8:55 PMid
field and unique constraint, and instead create a compound ID by doing @@id([challengeId, userId])
which I'm hoping will give you the indexed search you want.Chris Tsongas
03/24/2022, 8:57 PMmatic
03/24/2022, 9:13 PMmatic
03/25/2022, 5:20 AMJonathan
03/28/2022, 7:34 AMjanpio