EF 插入数据问题

__岑__ 2013-08-10 04:08:31

经测试要花80到100秒之间
请问如何优化?
...全文
456 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
__岑__ 2013-10-08
  • 打赏
  • 举报
回复
Hello all, I am the dev owning the identity feature. To boost the preformance for high end machines, we introduce preallocation for identity value in 2012. And this feature can be disabled by using TF 272 (then you will get the behaviour from 2008R2). The identity properties are stored separately in metadata. If a value is used in identity and increment is called, then the new seed value will be set. No operation, including Rollback, Failover, ..... can change the seed value except DBCC reseed. Failover applies for the table object, but no the identity object. So for failover, you can call checkpoint before manual failover, but you may see gap for unplanned cases. If gap is a concern, then I suggest you to use TF 272. For control manager shutdown, we have a fix for next verion (with another TF). This fix will take care of most control manager shutdown cases. Thanks, Bryan
__岑__ 2013-08-10
  • 打赏
  • 举报
回复
引用 8 楼 jshi123 的回复:
这么说是ef的效率问题,用下面这种试试时间多少? http://www.codeproject.com/Tips/297582/Using-bulk-insert-with-your-linq-to-sql-datacontex
0.16秒解决问题
jshi123 2013-08-10
  • 打赏
  • 举报
回复
这么说是ef的效率问题,用下面这种试试时间多少? http://www.codeproject.com/Tips/297582/Using-bulk-insert-with-your-linq-to-sql-datacontex
__岑__ 2013-08-10
  • 打赏
  • 举报
回复
第一个注释 ef savechanges方式插入 80-100s 第二个注释 ef调存储过程 33s 第一二个注释之间 执行sql语句 20s
__岑__ 2013-08-10
  • 打赏
  • 举报
回复
jshi123 2013-08-10
  • 打赏
  • 举报
回复
把数据表上的约束和索引先关掉试试,包括主键约束
在飞的特拉斯 2013-08-10
  • 打赏
  • 举报
回复
是不是时间耗在了生成随机数的地方,是否可以先生成完全部的随机数,然后再插入比较快呢?
__岑__ 2013-08-10
  • 打赏
  • 举报
回复
把这些数据查询读取出来很快 为什么插入那么慢?
__岑__ 2013-08-10
  • 打赏
  • 举报
回复
是不是我方法用错了?
__岑__ 2013-08-10
  • 打赏
  • 举报
回复

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧