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
Sybatron
Sybatron17mo ago
Do you use jsonprotocol
Mendy
Mendy17mo ago
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)
Sybatron
Sybatron17mo ago
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
Mendy
Mendy17mo ago
I get that, but it’s an empty db with literally 2 entries, also no cold starts problem as the dev server is upNruning
Rhys
Rhys17mo ago
@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?
Mendy
Mendy17mo ago
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.
Sybatron
Sybatron17mo ago
That's quite far you want your db closer to your server Where will be your server?
Mendy
Mendy17mo ago
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.
Sybatron
Sybatron17mo ago
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
Mendy
Mendy17mo ago
You’re right, will change now. I remember checking this… JsonProtocol is just for Postgres (for now) no?
bostonsheraff
bostonsheraff17mo ago
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
Mendy
Mendy17mo ago
I changed absolutely nothing but I see only 3s now.
Mendy
Mendy17mo ago
Mendy
Mendy17mo ago
Thank you, when reading the blog post I must’ve confused those two.
Mendy
Mendy17mo ago
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
Want results from more Discord servers?
Add your server