Creates a PostgreSQL adapter wired to a Hyperdrive binding.
The client is created once per request and reused for every statement in that
request, which is the pattern Cloudflare documents: Hyperdrive pools the
underlying connection, so creating a client is cheap, but each connect()
still acquires a pooled connection and the pooler runs in transaction mode.
Opening one per statement therefore acquires and releases a pooled connection
per statement and forfeits named prepared statements.
Caching a client in module scope is not the alternative: Workers reject I/O
created by one request and used by another. Either pass scope so the
provider can key its client on the current request, or call
HyperdriveProvider.dispose at the end of each request.
Creates a PostgreSQL adapter wired to a Hyperdrive binding.
The client is created once per request and reused for every statement in that request, which is the pattern Cloudflare documents: Hyperdrive pools the underlying connection, so creating a client is cheap, but each
connect()still acquires a pooled connection and the pooler runs in transaction mode. Opening one per statement therefore acquires and releases a pooled connection per statement and forfeits named prepared statements.Caching a client in module scope is not the alternative: Workers reject I/O created by one request and used by another. Either pass
scopeso the provider can key its client on the current request, or call HyperdriveProvider.dispose at the end of each request.