-
Couldn't load subscription status.
- Fork 347
Question : Does ExecuteReaderAsync() load result set progressively? #1025
-
Suppose using MySqlCommand.ExecuteReaderAsync() to load 1 million records without pagination, would this method return when some records are available before all records are received ?
Beta Was this translation helpful? Give feedback.
All reactions
The method returns as soon as the MySQL Server sends the "result set header" (which includes the list of columns included in the results) and before any rows have been read from the network. Rows are only read from the network connection when you call ReadAsync and NextResultAsync; it's not all read ahead of time and buffered in memory.
The other variable here is whether the MySQL Server "streams" the data to the client, or whether it first computes the whole million-row result set in memory and then writes it to the client. If the latter, it can seem like ExecuteReaderAsync "waits" until all the rows are available, but it's just dependent on when MySQL Server actually sends the data.
(An...
Replies: 1 comment
-
The method returns as soon as the MySQL Server sends the "result set header" (which includes the list of columns included in the results) and before any rows have been read from the network. Rows are only read from the network connection when you call ReadAsync and NextResultAsync; it's not all read ahead of time and buffered in memory.
The other variable here is whether the MySQL Server "streams" the data to the client, or whether it first computes the whole million-row result set in memory and then writes it to the client. If the latter, it can seem like ExecuteReaderAsync "waits" until all the rows are available, but it's just dependent on when MySQL Server actually sends the data.
(And technically, ExecuteReaderAsync returns a Task<MySqlDataReader> immediately, but I assume you were asking about when the Task is completed.)
Beta Was this translation helpful? Give feedback.