我怎样才能得到的LINQ到SQL的SubmitChanges百分比? [英] How can I get a percentage of LINQ to SQL submitchanges?

查看:292
本文介绍了我怎样才能得到的LINQ到SQL的SubmitChanges百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有人问过类似的问题。

I wonder if anyone else has asked a similar question.

基本上,我有一个巨大的树我使用LINQ对象建立在RAM中,然后我使用dump这一切一气呵成 DataContext.SubmitChanges()

Basically, I have a huge tree I'm building up in RAM using LINQ objects, and then I dump it all in one go using DataContext.SubmitChanges().

它的工作原理,但我找不到如何给用户一种多远具有查询视觉指示到目前为止取得了进展。如果我能最终实现一种进步吧,那将是巨大的,即使有性能上的损失最小。

It works, but I can't find how to give the user a sort of visual indication of how far has the query progressed so far. If I could ultimately implement a sort of progress bar, that would be great, even if there is a minimal loss in performance.

请注意,我有相当大量的行放入数据库,超过75万行。
我还没有计时弄到手,但它确实需要很长的时间才能把它们放在

Note that I have quite a large amount of rows to put into the DB, over 750,000 rows. I haven't timed it exactly, but it does take a long while to put them in.

编辑:我想我最好给我在做什么指示。

I thought I'd better give some indication of what I'm doing.

基本上,我建设从魔戒后缀树。因此,有很多节点,和某些节点具有相关联的对他们(即恰好是在一个后缀的端节点)的位置。我建立沿着这些线路的LINQ的对象。

Basically, I'm building a suffix tree from the Lord of the Rings. Thus, there are a lot of Nodes, and certain Nodes have positions associated to them (Nodes that happen to be at the end of a suffix). I am building the Linq objects along these lines.

suffixTreeDB.NodeObjs.InsertOnSubmit(new NodeObj()
{
    NodeID = 0,
    ParentID = 0,
    Path = "$"
});

在后缀树已经在RAM中得到了充分的生成(只需要几秒钟),然后我叫 suffixTreeDB.submitChanges();

After the suffix tree has been fully generated in RAM (which only takes a few seconds), I then call suffixTreeDB.submitChanges();

我想知道是是否有这样做的任何更快的方法。 !谢谢

What I'm wondering is if there is any faster way of doing this. Thanks!

修改2:我已经做了秒表,显然它需要精确6分钟为要写入的DB

Edit 2: I've did a stopwatch, and apparently it takes precisely 6 minutes for the DB to be written.

推荐答案

我建议你把你正在做的调用,因为它们在不同的呼叫反正送到分贝。这也将减少交易的大小(调用的SubmitChanges时,其LINQ如此)。

I suggest you divide the calls you are doing, as they are sent in separate calls to the db anyway. This will also reduce the size of the transaction (which linq does when calling submitchanges).

如果您在75.000 10块划分他们,你可以提供一个粗略的估计。1/10比例

If you divide them in 10 blocks of 75.000, you can provide a rough estimate on a 1/10 scale.

更新1:重新阅读您的文章和新的意见后,我想你应该看看SqlBulkCopy的替代。如果您需要提高操作的时间,这是要走的路。检查此相关的问题/回答:的 http://stackoverflow.com/questions/24200/whats-the-fastest-way-to-bulk-insert-a-lot-of-data-in-sql-server -c客户端/ 24224#24224

Update 1: After re-reading your post and your new comments, I think you should take a look at SqlBulkCopy instead. If you need to improve the time of the operation, that's the way to go. Check this related question/answer: http://stackoverflow.com/questions/24200/whats-the-fastest-way-to-bulk-insert-a-lot-of-data-in-sql-server-c-client/24224#24224

这篇关于我怎样才能得到的LINQ到SQL的SubmitChanges百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆