My DB shouldn’t be this slow, RIGHT❓
A fresh DB (pscale) and Table with just two entries, but takes 10s to fetch them (prisma studio)
I’m referring to dev mode, fetch through prisma studio, I haven’t deployed yet - so didn’t check prod.
It’s a user table with 4 one to many relationships, and a few fields.
User => chains[]
User => daycares[]
User => rooms[]
User => children[]
It’s all indexed (as mandatory by Prisma).
My connection is ok, but I’m regularly getting 10s loads, even with consecutive requests.
19 Replies
Do you use jsonprotocol
jsonprotocol is the new experimental prisma feature right? I’m not using it
Other then the schema I changed nothing from the t3 implementation
(t3-turbo to be exact)
It boosts the cold starts and the query performance and it should reduce the time
Also dev will be slower than production as it does additional work
I get that, but it’s an empty db with literally 2 entries, also no cold starts problem as the dev server is upNruning
@Mendy What region are you, what region are your functions in, and what region is your database in?
Is it slow locally as well or only in prod?
I’m in Israel, planetscale is in London, that’s literally all there is to it as everything other then the db is running locally
Only in dev, it’s a new setup and I didn’t deploy nothing yet
I will try to query the db tomorrow using raw sql ams without prisma, and report if I see better performance.
That's quite far you want your db closer to your server
Where will be your server?
The server will also be in London, it’s the closest region to Israel that Planetscale, Varcel, and Firebase (I’m using it for auth) offers.
But since the only think talking with the db is me from my local setup, the latency shouldn’t be an issue. It’s still relatively close to me.
Frankfurt should be closer and everyone has it
As its main region for europe
Thw problem is not how many users talk to the db right now
First you need to establish db connection to london then query to London
And on your local setup you have more of setup server close to client and not close to db
That adds to the latency
The whole burden that json protocol improves is still there for you too
So jsonprotocol hopefully removes few seconds from your dev setup
You’re right, will change now.
I remember checking this…
JsonProtocol is just for Postgres (for now) no?
JsonProtocol and "json fields" are 2 different things. JsonProtocol is just how prisma communicates with itself, and is available for all underlying DB (as a preview feature) https://github.com/prisma/prisma/issues/18095
"json fields" are actual table columns that hold json objects as their values https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields
I changed absolutely nothing but I see only 3s now.
Thank you, when reading the blog post I must’ve confused those two.
That’s the results with the jsonprotocol, it ok because coldstarts are not an issue when using prisma stuido so the advantage of the jsonprotocol is not so noticeable
Still 2-3 sec for a simple query on an empty db seems like a lot
I think this because of how far you are from the db
And you are dev mode from what I've seen 2s is regular in dev environment
Got it 👍
Thank you so much for your help!!!
@Sybatron
@bostonsheraff
Hi guys, how do I change Vercel's server region? I can only see option for functions