Skip to content

pool and client #693

Answered by porsager
skelawsky asked this question in Q&A
Oct 11, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Simplicity can indeed be confusing when coming back to it 🤣 Postgres.js has a default max of 10 connections, but if you want a single one, just set max: 1

Transactions are run using sql.begin, and will block a connection while running, but you don't need to do anything specific yourself. You can also use sql.reserve if you explicitly need to have access to a single connection from the pool for a short period, but this is not something you usually need unless you have a special case.

Connections are handled lazily, and with the best defaults, so a connection is not made until you make a query, and they are cycled and closed if idle per the defaults.

If you think something is lacking in the…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@henryzhang03
Comment options

Answer selected by skelawsky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants