You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Npgsql buffers rows by default, and can optionally even stream rows (when CommandBehavior.SequentialAccess is specified). However, there are some scenarios where resultset buffering may be appropriate:
Multiplexing (Productize multiplexing to make it user-ready #3991).
Since the same connection is shared by multiple consumers, if some applications performs any computation while consuming the resultset, that blocks everyone else waiting for later results. Npgsql would automatically buffer the entire resultset before returning the reader to the user, clearing up the connection to process results for other consumers.
Fake MARS (see Implement MARS (Multiple Active Result Set) #462).
Resultset buffering could allow the same connection to have multiple readers open at the same time - since they iterate over resultsets which are buffered in memory. I'm not sure this is something we should actually encourage though.
We could implement this by having an NpgsqlCommandBehavior (similar to System.Data's CommandBehavior).
One (obvious) thing that comes to mind... Resultset buffering can help with "problematic" resultset consumption patterns; but the same head-of-line issue also exists for queries which are simply slow on the server. In other words, users have to be aware of the head-of-line effects of multiplexing in any case, and possibly even segregate actual slow queries in their own, separate pool. That may be a good reason not to do resultset buffering, since users must be aware of this in any case and deal with it.
@NinoFloris benchmarked this for perf benefits (thanks to draining the resultset and returning the connection quicker to the pool) it did not pan out.
As a result, we don't currently believe there's a point to implementing this in Npgsql; feel free to post back here with further feedback and we'll reconsider.
Activity
roji commentedon May 15, 2022
One (obvious) thing that comes to mind... Resultset buffering can help with "problematic" resultset consumption patterns; but the same head-of-line issue also exists for queries which are simply slow on the server. In other words, users have to be aware of the head-of-line effects of multiplexing in any case, and possibly even segregate actual slow queries in their own, separate pool. That may be a good reason not to do resultset buffering, since users must be aware of this in any case and deal with it.
roji commentedon Nov 7, 2023
@NinoFloris benchmarked this for perf benefits (thanks to draining the resultset and returning the connection quicker to the pool) it did not pan out.
As a result, we don't currently believe there's a point to implementing this in Npgsql; feel free to post back here with further feedback and we'll reconsider.