New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDB: Simple findFirst()
query for primary key is slower than expected
#23950
Comments
findFirst()
query for primary key is slower than expectedfindFirst()
query for primary key is slower than expected
@janpio are you sure this is a this looks more like this issue #22812 i am pretty confident that findFirst does work properly and does not do a |
Yes, I am pretty sure that is what was reported:
If what was reported was wrong, we will figure this out when trying to reproduce and fixing. We have to go from what our users tell us. If it turns out to be incorrect, great, one less issue and this can be closed. @Davidaprilio Can you double check what I quote above from your comment message? |
I just tried it again, and sorry it turns out it really does use import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient({
errorFormat: 'pretty',
log: ['query', 'info', 'warn', 'error'],
})
async function run() {
const res = await prisma.message.findFirst({
where: {
id: '65c75988a71554b2fcd0c48d'
},
})
}
run() and in console (base) david@dell-office:~/Projects/***$ ts-node test/query.ts
prisma:query db.messages.aggregate([ { $match: { $expr: { $and: [ { $eq: [ "$_id", { $literal: ObjectId("65c75988a71554b2fcd0c48d"), }, ], }, { $ne: [ "$_id", "$$REMOVE", ], }, ], }, }, }, { $limit: 1, }, { $project: { _id: 1, delay.min: 1, delay.max: 1, deviceId: 1, priority: 1, status: 1, payload: 1, maxRetry: 1, expiredSendAt: 1, updatedAt: 1, createdAt: 1, type: 1, callbackUrl: 1, callbackType: 1, proccessId: 1, testing: 1, }, }, ])
(base) david@dell-office:~/Projects/***$ Maybe I used to take the query log wrong, but the query was really very heavy. |
Ok, does that mean that the original message was a mistake? If so, I think it would be good to close this issue to make sure that is properly tracked. I am not sure I am following with the further performance problem you describe. Do you think it is worth creating a new issue, with more information so we can fully understand and reproduce this? We would be very happy to do that. Thanks! |
Yes, you can close this issue and if you want to create a new issue about performance to improve I would be happy, because actually the problem from the start was performance and I was wrong in the query |
Sure, go ahead! Thanks. |
Originally posted by @Davidaprilio in #16916 (comment)
The text was updated successfully, but these errors were encountered: