Search code examples
c#sql-serverperformancetimerservice-broker

Service broker vs normal monitor performance


I want to monitor the changes on two tables (in large scale Database ) I have two options

  • SqlDependency and server broker
  • Normal timer every second to watch

From my perspective the second choice is not reasonable and headache , I have bad experience with timers

any suggestion regarding the best practice for that


Solution

  • Query Notifications (aka. SqlDependency) allows you to detect changes that would modify a query you already run. They are intended solely for cache invalidation.

    To track changes that occur in your tables, even while your client is offline, you need to consider Change Tracking or Change Data Capture.

    Timers are not an option under any circumstances. They cannot detect changes, they can only run again the same query.