Issues with Prisma <> Postgres <> Railway?
themkrage
PROOP

2 years ago

I'm running about 1000-1200 raw queries (logged through Prisma) in a few seconds and am getting wait times of 20-30 seconds for something that takes 1ms with pg's EXPLAIN ANALYZE.

I don't see anything spike in the Railway panels for our Postgres instance either. The only one that spikes is outbound, which hit about 120mb. I don't think that's unreasonable though and shouldn't be causing these long load times and backup.

It could be:

network latency (maybe we are querying too much info?)
a Prisma issue
a Postgres issue
a Railway config issue with Prisma and/or Postgres
Has anyone run into anything similar? Am I using Prisma incorrectly? I've barely changed any of the default settings.

15 Replies

themkrage
PROOP

2 years ago

98f66160-ce86-4b15-a73b-cab912256208


brody
EMPLOYEE

2 years ago

how are you connecting to the database? try using the private network if you aren't already


themkrage
PROOP

2 years ago

I am using a conneciton_url through Prisma that is essentially just the pg user / password. Can you elabroate on the private network?


brody
EMPLOYEE

2 years ago

try using DATABASE_PRIVATE_URL


themkrage
PROOP

2 years ago

Testing now, but i was hoping to have a solution that works even when running on localhost. As far as I know, 1000 queries in a 10 second query per user isn't anything crazy, right?


themkrage
PROOP

2 years ago

Just tested using the private database URL, this did not fix the issue and we are still seeing long load time


themkrage
PROOP

2 years ago

Any other ideas? @Brody


brody
EMPLOYEE

2 years ago

try making the same queries using raw SQL, as to eliminate prisma as the issue


themkrage
PROOP

2 years ago

I can try that. Do you have preferred typescript postgres client / lib that would be good to try this with?


brody
EMPLOYEE

2 years ago

I think the go to pg npm package would be more than sufficient


themkrage
PROOP

2 years ago

@Brody was able to confirm the issue still happens when using pg raw over prisma


brody
EMPLOYEE

2 years ago

and you are now connecting over the private network?


themkrage
PROOP

2 years ago

Yes! I set databaseurl to privatedatabase_url in my env vars


brody
EMPLOYEE

2 years ago

is there some postgres config you can tweak? the postgres databases railway deploys are not managed in any way, they are just the bog standard postgres docker images provided by postgres with SSL on top


themkrage
PROOP

2 years ago

I see. I just tried saving our data to a local postgres server and I'm still running into this issue, so I agree it's likely not a railway specific config thing. What sorts of postgres config hve you seen for issues like this? I'm absolutely baffled so any help would be appreciated


Loading...