mirromutth / r2dbc-mysql

R2DBC MySQL Implementation
Apache License 2.0
656 stars 100 forks source link

Whether R2DBC will wait for the EOF pushed by the MYSQL server? #166

Open kevinten10 opened 3 years ago

kevinten10 commented 3 years ago

Pre: MYSQL response data will be pushed to the client in a stream

When I use JDBC to access the MYSQL database, the thread will block until the MYSQL response data stream reaches the EOF mark, before all the data will be placed in memory.

So when I use non-blocking R2DBC to access MYSQL, do I still need to wait for the EOF mark of mysql to arrive before I can use the data in the memory? Or when a data packet arrives, if the water level of the NIO buffer is reached, then the application can be used instead of waiting for all the data to arrive.

For example, I have a big query. The MYSQL server will push from the 1st second to the 10th second to complete. JDBC can use the data after 10 seconds. Does R2DBC consume from the 1st second to the 10th second?

Looking forward to your reply!

mirromutth commented 3 years ago

Hi there,

Strictly speaking, the driver does not block any threads. Here I understand it as when to emit the first row data in the result stream.

There may have two EOF: metadata EOF and row data EOF.

In big/slow queries, the driver will immediately emit the first row when the metadata is ready (received metadata EOF) and receiving first row data. (Result.map(BiFunction<Row, RowMetadata, ? extends T> mapping)) Sure, if no row data following the metadata, it will just emit a complete signal.

Add more additional information to the example:

Then, the answer is "Yes, R2DBC MySQL consume from the 1st second to the 10th second".