Closed cquptzzy closed 1 year ago
As I understand you're using DbUtils with MySQL as database and the PooledDb conection pool.
The role of mincached
is illustrated here.
It's the number of connections that are at created in the pool and that will stay at minimum in the pool.
Yes, you can view these connections with show processlist
.
For instance, if you set up the pool like this, you should see 10 connections in the list:
db = PooledDB(pymysql, mincached=10)
When the program exists or db
is closed, the connections should disappear again.
It works similarly with other databases like PostgreSQL.
I hope this answers your questions.
Thank you very much. I see what you mean. It determines the number of connections at initialization and holds them. But it might automatically increase the number of connections as the number of requests gets larger, right?
But it might automatically increase the number of connections as the number of requests gets larger, right?
Right. The upper limit is controlled with the maxcached
parameter. When this limit is reached, no more connections are created, and you need to wait until one of the used connections is freed and put back into the pool.
ok ,I got it
Hello, first of all, I am not a native English speaker, so my expression may not be clear. I want to determine the role of mincached In the parameter introduction it is like this, mincached: the initial number of idle connections in the pool (the default of 0 means no connections are made at startup)
But there is this sentence in the introduction of pooleddb: Besides the pool of shared connections, you can also set up a pool of at least mincached and at the most maxcached idle connections that will be used whenever a thread is requesting a dedicated database connection or the pool of shared connections is not yet full.
Will pooleddb keep the connection based on mincached? Can this connection be observed using show processlist? Thank you so much