Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlDataReader.WillHaveEnoughData is pessimistic, can it read ahead? #533

Open
Wraith2 opened this issue Apr 20, 2020 · 1 comment
Open
Labels
💡 Enhancement New feature request 📈 Performance Use this label for performance improvement activities

Comments

@Wraith2
Copy link
Contributor

Wraith2 commented Apr 20, 2020

This is a nice-to-have idea bourne out of some performance investigation.

When doing calling into SqlDataReader.ReadAsync the internal function WillHaveEnoughData is called to see if it's possible to read another row from the current packet without needing to do IO, it calculates the maximum size of each field that could be fetched and uses that to work out if there is enough data present. In the case of strings the maximum size may often exceed the real size by a large amount causing preeimistic behaviour and allocation of a TaskCompletionSource where one Is not needed.

If possible it would be nice if WillHaveEnoughData could have a way to discover if enough column header information is present in the buffer already to determine the size of the next row and avoid the IO if possible. This may require the ability to peek forwards into the buffer by multiple tokens without consuming or doing io.

In practice this behaviour causes a ReadAsync with any variable length type to assume large amounts of data are needed causing task machinery overheads on all invocations where it is only needed in a fraction of the cases.

@cheenamalhotra
Copy link
Member

Thanks @Wraith2

Thanks for bringing suggestion for improvement, we will consider this sometime in future when we have bandwidth from high priority issues.

@cheenamalhotra cheenamalhotra added the 💡 Enhancement New feature request label Apr 21, 2020
@benrr101 benrr101 added the 📈 Performance Use this label for performance improvement activities label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Enhancement New feature request 📈 Performance Use this label for performance improvement activities
Projects
None yet
Development

No branches or pull requests

3 participants