Why is the first query on each request so slow?
On each request in the Nextjs App Router is the first query extremly slow. I connect to the database as follows:
I also tried this in a simple nodejs project without next and there it's works. Does anyone have any idea why this is so?
1 Reply
Assuming the queries are the same thing every invocation. The first one is probably cold start plus query execution time which makes sense since you said without next it’s fine.
The follow up query is gonna be making use of caching which is why it’s faster