Next.js Discord

Discord Forum

[Prisma] Noticeable delay between `Generated request` and actually sending it

Unanswered
Asian paper wasp posted this in #help-forum
Open in Discord
Asian paper waspOP
For the record, here are the logs:
Start fetching blog metadata: 2024-01-26T08:22:12.571Z
2024-01-26T08:22:12.753Z prisma:client  Prisma Client call:
2024-01-26T08:22:12.753Z prisma:client  prisma.blogMetadata.findUnique({
  where: {
    id: "6AyfMHZ9FHrk37dL817DI2"
  }
})
2024-01-26T08:22:12.754Z prisma:client  Generated request:
2024-01-26T08:22:12.754Z prisma:client  {
  "modelName": "BlogMetadata",
  "action": "findUnique",
  "query": {
    "arguments": {
      "where": {
        "id": "6AyfMHZ9FHrk37dL817DI2"
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}
2024-01-26T08:22:14.242Z prisma:client:libraryEngine  sending request, this.libraryStarted: true
Done fetching blog metadata: 2024-01-26T08:22:14.388Z (+1817ms)


As you can see, everything is looking fine except "Generated request" and "libraryEngine sending request", which for some reasons, there are a very noticeable delay between the two operations, slowing down the entire data fetching process. The application is deployed to Vercel's serverless ENV with Node.js as the runtime.

May I know if anyone has any insight on what's going on here? And how can I minimize the latency?

1 Reply

Asian paper waspOP
The problematic query:
prisma.blogMetadata.findUnique({ where: { id } });


And for some reason, these queries are fine.
prisma.blogMetadata.findMany({ where: { id: { in: ids } } });
prisma.contactFormSubmission.findMany({
  where: { showInGuestbook: true },
  orderBy: { submittedAt: 'desc' },
});