Postgresql R2DBC Statement.fetchsize exaclty的工作原理

Postgresql R2DBC Statement.fetchsize exaclty的工作原理,postgresql,reactive,r2dbc,r2dbc-postgresql,Postgresql,Reactive,R2dbc,R2dbc Postgresql,我正在使用驱动程序。假设我们有一个包含1000条记录的表,fetchSize为100: connectionMono.flatMapMany( connection -> connection .createStatement("select age from users") .fetchSize(100)

我正在使用驱动程序。假设我们有一个包含1000条记录的表,
fetchSize
为100:

connectionMono.flatMapMany(
                connection -> connection
                        .createStatement("select age from users")
                        .fetchSize(100)
                        .execute())

将执行多少网络呼叫?我知道,使用JDBC
语句.SetFetchsize
,驱动程序将以10个批次(每个批次100行)获取所有行。

查看r2dbc驱动程序中的代码,其行为是相同的:它以指定的大小逐块获取行,因此在您的情况下为100

以下是中的方法处理代码:

/**
*执行查询,并使用{@link Execute}消息指示获取块中的行。
*
*@param bindFlow初始绑定流
*@param要使用的客户端
*@param-portal门户
*@param fetchSize每次往返获取大小
*@返回生成的消息流
*/
私有静态Flux fetchCursored(Flux bindFlow、客户端、字符串门户、int fetchSize){
DirectProcessor requestsProcessor=DirectProcessor.create();
FluxSink requestsSink=requestsProcessor.sink();
AtomicBoolean isCanceled=新的AtomicBoolean(false);
返回client.exchange(bindFlow.concatWithValues(新的CompositeFrontendMessage(新的Execute(portal,fetchSize,Flush.INSTANCE)).concatWith(requestsProcessor))
.handle((后端消息消息,SynchronousSink)->{
if(命令完成的消息实例){
下一步(新关闭(门户,门户));
requestsSink.next(Sync.INSTANCE);
requestsSink.complete();
sink.next(消息);
}else if(错误响应的消息实例){
requestsSink.next(Sync.INSTANCE);
requestsSink.complete();
sink.next(消息);
}else if(PortalSuspended的消息实例){
if(isCanceled.get()){
下一步(新关闭(门户,门户));
requestsSink.next(Sync.INSTANCE);
requestsSink.complete();
}否则{
next(新执行(门户,fetchSize));
requestsSink.next(Flush.INSTANCE);
}
}否则{
sink.next(消息);
}
})
.as(通量->运算符.discardOnCancel(通量,()->iscanceld.set(true));
}