default MaxConnections to runtime.NumCPU()
I think MaxConnections of ConnPoolConfig should default to runtime.NumCPU()
I think there are 2 cases:
- MaxConnection may be limited be application architecture (for example only 3 threads can make db request). For this case defaults to number of cpu is useless.
- MaxConnection can be limited by system performance (for example high load app). In this case
NumCPUis not an ideal: what if db server has 64 cores, but app server has only 4 cores and performs hard-for-db-server quires?
As a result NumCPU looks not better than current "5". I think it is better to require always set this parameter manually.
MaxConnections should usually be determined by the server. A general rule for a PostgreSQL server is the server is most efficiently used with around 2 * numCores connections (https://wiki.postgresql.org/wiki/Number_Of_Database_Connections).
However, there is no way for a client application to know the resources of the server and the resources used by other clients.
5 is simply a safe default that allows some parallelism on the client side and ensures that it doesn't consume an unexpectedly high amount of server connections.