I need a little help understanding the difference between a "pool" and a "pooled client." I think my confusion is a result of the inconsistent usage of these terms in the
documentation for the PostgresSQL Client.
From what I understand so far, PgPool.pool() creates a pool of connections...
static PgPool pool(Vertx vertx, List<PgConnectOptions> databases, PoolOptions poolOptions) {
return (PgPool) PgDriver.INSTANCE.createPool(vertx, databases, poolOptions);
}
And PgPool.client() looks like it too creates a "pool" (?), but unlike PgPool.pool(), pipelining is enabled...
static SqlClient client(Vertx vertx, List<PgConnectOptions> databases, PoolOptions options) {
return PgDriver.INSTANCE.createPool(vertx, databases, new PgPoolOptions(options).setPipelined(true));
}
Does the choice to use
PgPool.pool() over
PgPool.client() just come down to whether or not you want pipelining? Here's where I think I start getting confused. The example in the "
Pool versus pooled client" section of the docs appears to imply that
PgPool.pool().query() will
not be pipelined whereas
PgPool.client().query() will. So far so good, but if you look at the example in the previous section (
Command Pipelining), it sounds like you actually can enable pipelining in
PgPool.pool() after all?
PgPool pool = PgPool.pool(vertx, connectOptions.setPipeliningLimit(16), poolOptions);
Also, if you search the documentation page for the exact phrase "the pooled client" (e.g., used in code comments from the examples) you'll find it flip-flops between being associated with both PgPool.pool() and PgPool.client().
These two bullet points are from the docs:
- pool operations are not pipelined, only connections acquired from the pool are pipelined
- pooled client operations are pipelined, you cannot acquire a connection from a pooled client
Is the first bullet point referring to PgPool.pool() and the second to PgPool.client() or do I have that reversed?
The second bullet point notes that "you cannot acquire a connection from a pooled client." Does this mean then it's not actually a "pool of connections" despite PgPool.client()'s underlying call to PgDriver.INSTANCE.createPool()? Is PgPool.pool() generally preferred?
The docs mention to use a "pool" to connect to PostgreSQL "most of the time".
According to the docs, an example to illustrate that point used
PgPool.client(), but shouldn't that example use
PgPool.pool() instead?
Any help is appreciated!