DB speed is slow
Hello i am from tinylabs, we are building our application via using neon db, using the scale package. However, the performance of the database quries are significatly slow when we compare with the our other products. How can we increase the db performance?
17 Replies
extended-salmon•2mo ago
Hey! How are you using the database? It's rarely the database itself that's the issue, more likely how you're connecting / networking issue.
correct-apricotOP•2mo ago
We are connecting through prisma orm in hertzner server, nest js application, i do tests and local db was 3.5x faster than the neondb
extended-salmon•2mo ago
If that  3.5x metric includes round-trip, that’s almost certainly network. Is your Hetzner server located close to the region you provisioned your database in? Also, are you using the new Neon adapter for Prisma?
Though, just to set expectations, a hosted DB will never match localhost latency. Your local test has zero network hop since the app and DB share the same machine.
correct-apricotOP•5w ago
neon adapter? how can i use it
Hertzer located in germany
extended-salmon•5w ago
Is your database provisioned in aws-eu-central-1 for AWS or azure-gwc for Azure? Those will offer the lowest latency since they are physically the closest to your app's server. 
As for the neon adapter, you check it out here : https://neon.com/docs/guides/prisma#use-the-neon-serverless-driver-with-prisma
Neon
Connect from Prisma to Neon - Neon Docs
Prisma is an open source, next generation ORM that lets you to manage and interact with your database. This guide covers the following topics Connect to Neon from Prisma Use connection pooling with Pr...
correct-apricotOP•5w ago
we created on us-east-2
extended-salmon•5w ago
To change region you'll need to create a new project, and migrate over your data. The best way to do this is using the import data assistant : https://neon.com/docs/import/import-data-assistant
Neon
Import Data Assistant - Neon Docs
When you're ready to move your data to Neon, our Import Data Assistant can help you automatically copy your existing database to Neon. You only need to provide a connection string to get started. You ...
correct-apricotOP•5w ago
we transfared our db to usa because the frankfurt servers was slower
extended-salmon•5w ago
You’ll get the best performance when your app server and database are in the same region. If your app is on Hetzner in Germany, keep Neon in ws-eu-central-1/azure-gwc so you’re not adding cross-region network latency to every query. Co-locating both in a US region also works, just don’t split one in EU and one in US.
correct-apricotOP•5w ago
i got it, what is the purpose of the adapter?
extended-salmon•5w ago
It runs the SQL that the Prisma query generator creates through the Neon serverless driver.
correct-apricotOP•5w ago
does it affect the performance
extended-salmon•5w ago
On serverless/edge or short-lived runtimes, it reduces connection overhead. If you have a long lived Node server with warm connections then there won't be a difference.
correct-apricotOP•5w ago
we have nest js application
the db is real slow
we could not fix the issue
germany is not fast or usa
extended-salmon•5w ago
How slow is slow? From your nest application, can you run a SELECT 1 against a warm neon database (run the query twice to make sure you're not measuring cold start times).
correct-apricotOP•5w ago
SELECT 1? what is it, can you tell me the steps more detailed
extended-salmon•5w ago
SELECT 1; is a trivial query which we'll use measure your baseline round-trip latency (network + driver). Log how long a SELECT 1 takes in your Nest app (run it twice to avoid cold start)
and do it with your app and database server collocated