Prisma Query Performance Question
I have a nextjs application built with trpc endpoints and Prisma (also using Prisma Postgres - here is my schema). Most of my queries are pretty quick and dont give me any concern about performance, but one of my queries is noticeably slow (get all). This request is made from a trpc endpoint. I think it is fair to assume that this query could be slower than others given it is loading more data, but it is incredibly slow (initial load sometimes taking 3+ seconds and I only have 24 recipes in the db) relative to the rest of my queries.
What is even more interesting is this query is shared between pages, and it seems to only be slow on one page. I know there are a handful of variables at play here, but looking at my schema and query, are there any obvious issues I have/improvements to be made (schema index’s, etc).
To test this out live here are the 2 deployed pages on my site:
- Recipe list - this page provides the optional categories prop in the query input
- Recipe build - this page provides the optional ingredients prop in the query input
Both pages provide empty arrays for their respective inputs on initial page load, so I’d expect them to have similar initial load times, but /build seems to be consistently faster than /recipes. Please let me know if anyone has questions to help clarify the problem.
What is even more interesting is this query is shared between pages, and it seems to only be slow on one page. I know there are a handful of variables at play here, but looking at my schema and query, are there any obvious issues I have/improvements to be made (schema index’s, etc).
To test this out live here are the 2 deployed pages on my site:
- Recipe list - this page provides the optional categories prop in the query input
- Recipe build - this page provides the optional ingredients prop in the query input
Both pages provide empty arrays for their respective inputs on initial page load, so I’d expect them to have similar initial load times, but /build seems to be consistently faster than /recipes. Please let me know if anyone has questions to help clarify the problem.