Skip to content

QueryUnbufferedAsync with FirstAsync is slow if the query returns lots of records #2115

Closed
@cph0

Description

@cph0

Using the System.Linq.Async NuGet Package.

var query = "SELECT * FROM table";
var cnn = ...
var firstRecord = await cnn.QueryUnbufferedAsync<type>(query).FirstAsync();
cnn.close();

If "table" has millions of rows this is slow. IAsyncEnumerable is designed to be more efficient, at least from a memory point of view. But when calling FirstAsync you would expect it to run quickly as each row is returned to the calling code when it is read.

The reader is being disposed without cancelling the command first. I did look at using ExecuteReaderAsync but I can't get access to the command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions