HTTP vs. WebSockets: Which protocol for your Postgres queries at the Edge
SQL-over-HTTP has been added to the Neon driver, which previously only supported WebSockets, for querying Postgres databases closer to end-users. WebSockets excel in maintaining consistent connections, offering low latencies for sustained queries but perform slower for single-shot queries. By contrast, HTTP is quicker for single-shot queries but lacks features like session support and interactive transactions. To strike a balance, connection caching was introduced, speeding up HTTP queries by around 10ms. The choice between HTTP and WebSockets depends on query type, user location, and specific APIs used.