Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring database changes without using 'SqlDependency' class

I'm currently using Microsoft SQL Server 2008.

My production server has a very heavy load.

My C# application uses 'SqlDependency' class in order to monitor some table changes.

On development environment - the application works fine, and the change events from the SQL server gets fired correctly.

On production environment - the application gets change events even when there wasn't any change. I have read that the 'SqlDependency' doesn't perform well on heavy load.

I'm looking for other solution to this scenario, any suggestions ?

like image 928
ohadinho Avatar asked Nov 26 '25 05:11

ohadinho


1 Answers

If you get notified when there is no change it means something else triggered the notification. You must always inspect the SqlNotificationEventArgs argument received on your OnChange handler and react appropriately based on the Info, Source and Type. In production you very likely get a notification like Info.Options signifying incorrect SET options (ie. an environment specific problem).

As for the comment about SqlDependency under load, you will have to link the source. But query notification overall is designed for cache invalidation of data that changes seldom.

like image 197
Remus Rusanu Avatar answered Nov 27 '25 17:11

Remus Rusanu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!