Search code examples
spring-dataspring-data-r2dbcr2dbcr2dbc-postgresql

What's the bottleneck in Spring r2dbc database connection?


I've set up a sample project using spring boot, webflux, and r2dbc. I've been able to stream rows from a postgres db table to the client.

Is there a memory bottleneck on this server implementation (for storing the results of the query)? Do the rows stream through?

PS I'm not claiming any level of quality on this, I know pagination and so on would be essential, just wondering about how the db query interacts with the reactive framework.


Solution

  • Pagination is not essential with R2DBC. If you have a lot of rows to process you can issue a single query instead of fetching batches. The driver uses back-pressure to allow flow control so it does not overwhelm your application. You could read here about how backpressure is applied on such queries.