-
-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Currently, when pool.query()
(or pool.connect()
) is run, the default behavior is to reset the connection before the promise resolves with DISCARD ALL
. While this is great & safe default behavior, it means that all queries that use a connection pool must pay the the cost of waiting for DISCARD ALL
, which happens when await connection.release()
is run. This adds an additional back-and-forth roundtrip to the database for every query executed, and the result of the query isn't used by the client in the returned result.
Desired Behavior
It would be great to be able to set up the pool to run DISCARD ALL
(or a custom query) after the results of the query are returned to the client, but before the connection is returned back to the pool. This would keep the safe DISCARD ALL
behavior while reducing the latency back to clients that don't care about the result of DISCARD ALL
.
Motivation
DISCARD ALL
isn't slow, but it can take ~5-50ms in the worst case (and of course it depends on the database size and network latency). This time is currently being added onto every query by default, and it would be great to have the option for DISCARD ALL
to happen after the results of the query are returned.