From 449404d09d8599502b48a2310f1a9dfebbc376a0 Mon Sep 17 00:00:00 2001 From: ZhangCheng Date: Thu, 23 Nov 2023 14:53:42 +0800 Subject: [PATCH] Use ArrayList to optimize executeBatch performance --- .../driver/executor/batch/BatchExecutionUnit.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchExecutionUnit.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchExecutionUnit.java index 00e6162b4cb2e..38432deabe161 100644 --- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchExecutionUnit.java +++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchExecutionUnit.java @@ -25,6 +25,7 @@ import lombok.ToString; import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -66,7 +67,7 @@ public List> getParameterSets() { if (executionUnit.getSqlUnit().getParameters().isEmpty() || 0 == actualCallAddBatchTimes) { result.add(Collections.emptyList()); } else { - result.addAll(Lists.partition(executionUnit.getSqlUnit().getParameters(), executionUnit.getSqlUnit().getParameters().size() / actualCallAddBatchTimes)); + result.addAll(Lists.partition(new ArrayList<>(executionUnit.getSqlUnit().getParameters()), executionUnit.getSqlUnit().getParameters().size() / actualCallAddBatchTimes)); } return result; }