From 747569fe410ac3cef8e7f708b5499adf7186cdd0 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 8 Dec 2018 17:17:24 +0800 Subject: [PATCH] Batch insertion performance optimization --- .../SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs index c1efa0074..cf0a1421e 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs @@ -126,6 +126,14 @@ namespace SqlSugar { StringBuilder batchInsetrSql = new StringBuilder(); int pageSize = 200; + if (this.EntityInfo.Columns.Count > 30) + { + pageSize = 50; + } + else if (this.EntityInfo.Columns.Count > 20) + { + pageSize = 100; + } int pageIndex = 1; int totalRecord = groupList.Count; int pageCount = (totalRecord + pageSize - 1) / pageSize;