perf(agent): use single execute_transaction RPC for batch commits

This commit is contained in:
t8y2 2026-05-13 05:34:01 +08:00
parent 70db1eb9a9
commit 831883f156
1 changed files with 12 additions and 0 deletions

View File

@ -675,6 +675,18 @@ async fn exec_tx_explicit_inner(
schema: Option<&str>,
start: std::time::Instant,
) -> Result<db::QueryResult, String> {
let conns = state.connections.read().await;
if let Some(crate::connection::PoolKind::Agent(client)) = conns.get(pool_key) {
let mut client = client.lock().await;
let params = serde_json::json!({
"statements": statements,
"schema": schema,
});
let result: db::QueryResult = client.call("execute_transaction", params).await?;
return Ok(db::QueryResult { execution_time_ms: start.elapsed().as_millis(), ..result });
}
drop(conns);
do_execute(state, pool_key, "BEGIN", schema, None)
.await
.map_err(|e| format!("Failed to begin transaction: {}", e))?;