Today, we are thrilled to announce the release of our enhanced driver for your Postgres queries at the Edge.
With this release, developers can observe a 40% reduction in query latencies from Vercel Serverless Functions and Edge Functions, bringing same-region queries down to single-digit milliseconds and leading to a faster user experience.
You can also check out Vercel’s benchmark for Edge Functions to test the latencies.
Getting started with the driver
Here is an example of how to use the driver with Vercel Edge functions:
Using Drizzle-ORM and Neon serverless driver
We worked closely with the team behind Drizzle-ORM, an ORM for TypeScript, to add support for this release. Here is an example of how you can use the driver with Drizzle-ORM for type safety:
Why is the driver faster?
In short, the performance gains are with one-shot queries and primarily due to adding support for SQL-over-HTTP via fetch to the driver and adding support for cached connections to Neon’s proxy.
One-shot queries are the first queries executed from your Serverless or Edge Functions. Those traditionally require establishing a connection, where round-trips can increase latency.
Connection caching is experimental and opt-in only. You can try it by setting fetchConnectionCache
to true in the neonConfig
object.
Additionally, the driver is backward-compatible and works seamlessly with your existing Neon and Vercel Postgres code.
Pool or neon? Which one should I use?
If you are executing a single query from your Serverless or Edge Function, we recommend switching to the new syntax and use neon
to observe better latency. However, if you execute multiple queries, then create a new connection with Pool
.
As the edge computing landscape evolves, we are committed to improving latencies and how users interact with your applications. We invite you to try Neon and explore the benefits the new driver brings to your applications and welcome your feedback on our community forum as we continue to improve Neon to serve your needs better.