Skip to content

Support Min connection pool parameter #3009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Smriti-OSS opened this issue Jun 13, 2023 · 3 comments
Open

Support Min connection pool parameter #3009

Smriti-OSS opened this issue Jun 13, 2023 · 3 comments

Comments

@Smriti-OSS
Copy link

Smriti-OSS commented Jun 13, 2023

Hey @brianc @charmander ,

Problem Statement: I have an application which is currently using the default configuration of node-postgres pool to connect to postgres. I have noticed that whenever we query the application - node-postgres connection pool always creates a new connection and so the total time taken for query execution is always between 3-5sec. If we re-use an idle connection for query execution - it just takes 2 millisecond to 300 millisecond.

Proposed Solution: I am thinking of keeping some idle connections in the pool - so that they could be used whenever the database is queried. Something like this -

let pool = new Pool({
        database: connectionConfig.database,
        port: connectionConfig.port,
        user: connectionConfig.user,
        password: connectionConfig.password,
        host: connectionConfig.host,
        min: 1,
        max: 10
    });

I am open to submitting a PR for the above feature but thought of first discussing it with the community whether this would be a feature worth exploring.

@khoirulamri
Copy link

I experienced the same problem. each initial set of connections takes more than 200 ms, so the api response time becomes > 1s

@capJavert
Copy link

@brianc we are working with pg-pool and would really benefit from this option. My question is, is there any issue on driver level that would block implementing something like that?

I took a brief look at the code and it seems like it should be possible as an addition to pool logic. Would offer to contribute as well 🙌

@htrajan
Copy link
Contributor

htrajan commented Apr 24, 2025

I took a crack at addressing this. Would love to get your thoughts @brianc @charmander.

brianc pushed a commit that referenced this issue Apr 25, 2025
* Support Min connection pool parameter #3009

* Remove extraneous change

* streamline code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants