.NET的SqlDependency有多少条通知与高投票率?有多少、通知、NET、SqlDependency

由网友(爱情这出戏ヽ我演技太差)分享简介:我有一个小桌子(约200行),它时刻都在变化(夫妇次每秒)。我一直在寻找一个解决方案,我可以从数据库中每一个它的变化,而不是投票的时间收到通知它(比方说每秒5-10次)。I have a small table (approx. 200 rows) which changes all the time (coup...

我有一个小桌子(约200行),它时刻都在变化(夫妇次每秒)。 我一直在寻找一个解决方案,我可以从数据库中每一个它的变化,而不是投票的时间收到通知它(比方说每秒5-10次)。

I have a small table (approx. 200 rows) which changes all the time (couple of times per second). I was looking for a solution where i could receive notification from the database each time it changes, rather than polling it (let's say 5-10 times per second).

此外,我想每一个时间,而不是获取整个表只接收更改的行 - 我发现这个比较难实现这个使用的SqlDependency类

Moreover, i would like to receive only the changed rows each time and not fetching the whole table - i have found this rather difficult to implement this utilizing SqlDependency class.

几件事情要好好考虑下:

Couple of things to take under consideration:

在我没有过变化表控制还是我一定要获得比使用数据库中的其他数据的能力。 我打算建立,这将更改广播给我的面前服务器服务

有没有办法做到这一点使用的SqlDependency?

Is there a way to do this using SqlDependency?

什么是赋予这种情况下,最好的做法是什么?

What is the best practice given this case?

BTW:我使用的SQL Server 2012

BTW: i am using SQL server 2012

在此先感谢

推荐答案

的SqlDependency只会通知您发生了变化,你就必须重新读取整个表。它可以很好地通知率低。在较高的速度,你必须考虑到,通知有显著的成本。请参见神秘的通知了解更多详情的SqlDependency是如何工作的。正如你看到罐,有显著的成本:

SqlDependency will only notify you that a change occurred, and you'll have to re-read the entire table. It works well with a low rate of notifications. At a high rate, you have to consider that notifications have a significant cost. See The Mysterious Notification for more details how SqlDependency works. As you cans see, there is significant cost:

设置的通知(写sys.dm_qn_subscriptions和SSB系统表) 射击的通知(写sys.dm_qn_subscriptions) 提供的通知(写在SSB系统表,目标队列) 在收到通知(写入目标队列,SSB系统表)

这是相当多的写操作,成本会迅速增加,如果你得到通知不断。

That's quite a few writes, the cost will add up quickly if you get notified constantly.

但真正的问题是,究竟是如何要在应用程序能够响应变化的恒定速率?你有什么想知道的,是的的东西的变化?好了,你知道,它总是这样,无论何时在应用软件需要更好地阅读最新状态的数据,因为它确实改变了。轮询没有意义无论是。听起来像你真正想要的是要么变更跟踪< /一>或,更可能的是,更改的基于定制队列喂的变化发起者。

But the real question is how exactly do you want to react in the application to a constant rate of change? what do you want to know, that something changed? well, you know, it always does, anytime the application needs the data it better read the latest state, because it certainly changed. Polling does not make sense either. Sounds like what you really want is either change tracking or, more likely, a custom based queue of changes fed by the change originators.

阅读全文

相关推荐

最新文章