Skip to content

Implement resultset buffering #3990

Closed as not planned
Closed as not planned

Description

@roji

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).

Activity

  1. added this to the 7.0.0 milestone on Sep 24, 2021
  2. roji commented on May 15, 2022

    @roji
    MemberAuthor

    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.

  3. modified the milestones: 7.0.0, 8.0.0 on Sep 11, 2022
  4. roji commented on Nov 7, 2023

    @roji
    MemberAuthor

    @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.

  5. removed this from the 8.0.0 milestone on Nov 7, 2023
  6. added theissue type on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions