Slow database Postgres connection with Laravel

stefsiekman
PRO

3 months ago

For some reason, the first query that is made on each request takes surprisingly long (250ms up to 750ms). I'm assuming this is due to that query actually opening the database connection. Is there anything I can do in the database service setup to increase the performance? I've tried to remove the RAM limit, but that didn't seem to have any effect. Perhaps connection pooling? Any help would be appreciated! (I'm running Laravel with Postgres)

See the screenshot for an example, taken in Laravel Telescope: https://cln.sh/3zllyRjvPGGR8XT2LqYJ

Awaiting User Response

1 Replies

2 months ago

Hello,

Yep, you've answered your own question perfectly, a global connection pool is what is needed, you definitely take a massive performance hit if you open a database connection for every database call.

Unfortunately, we are not able to help you with the implementation as these forums are for Railway product and platform support only.

Best,
Brody


Status changed to Awaiting User Response railway[bot] 3 months ago


Slow database Postgres connection with Laravel - Railway Help Station