Skip to content

Implement CommandBehavior.SequentialAccess #1276

Open
@bgrainger

Description

@bgrainger

The CommandBehavior.SequentialAccess flag is a hint to the ADO.NET library that rows should not be buffered in memory before being returned. This could reduce memory usage and improve performance for large BLOBs.

This might end up being a significant refactoring of the ResultSet and Row classes:

  • ScanRowAsync would no longer wait for the entire payload to be received, but just the header byte (to know if EOF or new row)
  • GetValue would be required to be called in ordinal order, would discard data for columns before the current one, and would potentially block while waiting for more network data to arrive for the desired column
  • GetFieldValueAsync<T> should be overridden and do the same, but with proper async support
  • GetStream would return a custom Stream implementation that returns bytes off the network as they become available (and doesn't support rewinding)
  • GetBytes and GetChars would allow forward-only access to chunks of data in the column.

Perhaps it would be easiest to implement this by adding a new derived class (of ResultSet, and two new Row classes) and overriding methods to implement the streaming as necessary?

Activity

bgrainger

bgrainger commented on Jan 6, 2023

@bgrainger
MemberAuthor

adding a new derived class

FWIW, it sounds like Npgsql used to have something similar (two separate DataReader classes for sequential and non-sequential), but merged them back into one class: npgsql/npgsql#2328.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bgrainger

        Issue actions

          Implement `CommandBehavior.SequentialAccess` · Issue #1276 · mysql-net/MySqlConnector