You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/09/12 14:32:15 UTC

[GitHub] [skywalking] chenyi19851209 commented on a change in pull request #7691: tidb write by batch sql ,improve write speed.

chenyi19851209 commented on a change in pull request #7691:
URL: https://github.com/apache/skywalking/pull/7691#discussion_r706846855



##########
File path: oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2BatchDAO.java
##########
@@ -81,6 +92,36 @@ public void flush(List<PrepareRequest> prepareRequests) {
         }
     }
 
+    private void executeSql(List<PrepareRequest> prepareRequests, int maxBatchSqlSize) {
+        if (log.isDebugEnabled()) {
+            log.debug("execute sql batch. data size:{}", prepareRequests.size());
+        }
+        Map<String, List<PrepareRequest>> batchRequestMap = new HashMap<>();
+        for (PrepareRequest prepareRequest : prepareRequests) {
+            SQLExecutor sqlExecutor = (SQLExecutor) prepareRequest;
+            if (batchRequestMap.get(sqlExecutor.getSql()) == null) {
+                List<PrepareRequest> prepareRequestList = new ArrayList<>();
+                batchRequestMap.put(sqlExecutor.getSql(), prepareRequestList);
+            }
+            batchRequestMap.get(sqlExecutor.getSql()).add(prepareRequest);
+        }
+        try (Connection connection = h2Client.getConnection()) {
+            try {
+                for (String key : batchRequestMap.keySet()) {
+                    BatchSQLExecutor batchSQLExecutor = new BatchSQLExecutor(key, batchRequestMap.get(key));

Review comment:
       ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org