Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大批量数据操作的性能优化方案 #14

Open
ren8179 opened this issue Apr 22, 2020 · 0 comments
Open

大批量数据操作的性能优化方案 #14

ren8179 opened this issue Apr 22, 2020 · 0 comments

Comments

@ren8179
Copy link
Owner

ren8179 commented Apr 22, 2020

方案1

合并sql语句,只打开一次数据库连接.

存在的问题:
要控制执行的SQL语句大小

方案2

通过参数化和“Insert...Select”的SQL语句,一次性插入所有记录

存在的问题:

  1. 合并后的SQL用到参数化,但数据库限制参数最多2100个
  2. 数据量特别大时,产生的SQL语句依然很大

方案3

通过SqlBulkCopy机制,快速的将待保存数据一次性插入到数据库的临时表,SQL语句通过关联临时表进行批量新增、修改、删除

参考文章:

如何解决大批量数据保存的性能问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant