Thoughts from Dan Miser RSS 2.0
 Tuesday, June 27, 2006
I just spent some time checking out how SqlDependency works. SqlDependency is an ADO.NET 2.0 class that is a high level wrapper for detecting changes in a database and getting automatic notification back to your application. This technology is very useful for caching rarely changing data. Essentially, you register interest in a query, and if something changes that would make that query different, you get a callback to your application to let you know that you need to update your local cache.

All in all, it's a pretty mixed review right now. It's pretty stringent on the requirements, not terribly efficient, and probably not the most practical thing for a multi-tier system. However, what it does, it does well. Here is my quick list of things learned:

  • You need to make sure that the DB is compatible with MSSQL2005. You can set the compatibility level in SQL Server Management Studio by selecting the Properties page of the database.
  • You need to SET ENABLE_BROKER on the database, along with making sure other OPTIONS are in compliance, to allow Query Notifications to work.
  • Be sure to prefix the table in the select with the schema information (e.g. select CategroyId, CategoryName from dbo.Categories). Also be sure to check out the documentation for other limitations on queries.
  • The OnChange event fires once and then gets consumed, so you need to hook up the event again after it fires.
  • OnChange runs in a separate thread, so be sure to update the UI properly.
  • The Queues and Services in MSSQL 2005 are not being automatically deleted when you call SqlDependency.Stop. This is a known issue, and the query to delete the extra objects can be found in this discussion.
  • It appears that the notification fires if ANY field in the table tied to the query is changed - even if that field is not part of the query you registered for notification. This seems like a bug to me.
  • Query Notifications are not very granular in reporting WHAT changed. Right now, this essentially forces you to invalidate an entire cache as opposed to just updating individual elements that have changed.
  • SqlDependency is the high-level wrapper. You can also use the low-level SqlNotificationRequest class to get more control over the process, if you so choose.
  • For ASP.NET, you will most likely use the SqlCacheDependency class.
  • Oracle also has support for this technology. Check out the article, Following the changes. Part I and Part II.

Other resources:

Tuesday, June 27, 2006 9:08:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

Tracked by:
http://blog.rogerware.com/blog/PermaLink,guid,2db51e2b-b7e4-43ca-909b-da70f0c177... [Pingback]
http://9nv-information.info/95359945/index.html [Pingback]
http://9nc-information.info/90838480/index.html [Pingback]
http://9nl-information.info/49918838/index.html [Pingback]
http://9nu-information.info/01915987/index.html [Pingback]
http://9nu-information.info/03751862/index.html [Pingback]
http://9ni-information.info/13089606/405-u-s-a-pottery-pottery.html [Pingback]
http://9nx-information.info/71231195/computer-dictionary-project.html [Pingback]
http://9nr-information.info/38491772/index.html [Pingback]
http://9nq-information.info/90506206/index.html [Pingback]
http://9qi-information.info/29254562/index.html [Pingback]
http://9qf-information.info/79167999/index.html [Pingback]
http://9qc-information.info/50268083/index.html [Pingback]
http://9ov-information.info/11160781/social-security-post-traumatic-stress-disor... [Pingback]
http://9od-information.info/40061838/index.html [Pingback]
http://9oy-information.info/05830324/index.html [Pingback]
http://9oc-information.info/68326509/index.html [Pingback]
http://9ss-information.info/80005417/inno-milan-ufficiale.html [Pingback]
http://9sc-information.info/32058695/sito-internet-ottimizzazione.html [Pingback]
http://9rh-information.info/76451387/ocean-city-new-jersey-hotel-with-indoor-poo... [Pingback]
http://9sl-information.info/66166200/index.html [Pingback]
http://9ru-information.info/18543004/index.html [Pingback]
http://9rq-information.info/31685333/index.html [Pingback]
http://9rq-information.info/75059682/toyota-truck-camper.html [Pingback]
http://9sc-information.info/55278052/atos-origin-hp.html [Pingback]
http://9rs-information.info/73453621/index.html [Pingback]
http://9rm-information.info/12130984/cbs-medium-tv-show-mn-news-psychi.html [Pingback]
http://9uaej-le-informazioni.info/70918613/index.html [Pingback]
http://9uafn-le-informazioni.info/66197803/index.html [Pingback]
http://9uafr-le-informazioni.info/19639150/vendita-casa-bormio.html [Pingback]
http://9uaes-le-informazioni.info/81906723/index.html [Pingback]
http://9uaet-le-informazioni.info/93146899/index.html [Pingback]
http://9uaef-le-informazioni.info/71020472/temi-sfondi.html [Pingback]
http://9uahi-le-informazioni.info/45079106/index.html [Pingback]
http://9uahj-le-informazioni.info/42488036/index.html [Pingback]
http://9uagc-le-informazioni.info/24832907/index.html [Pingback]
http://9uagk-le-informazioni.info/96422340/index.html [Pingback]
http://9uahf-le-informazioni.info/91282387/index.html [Pingback]
http://9uahr-le-informazioni.info/78329425/index.html [Pingback]
http://9uags-le-informazioni.info/18796375/auguri-pasqua-frasi.html [Pingback]
http://www.google.com/search?q=bhwffkgk [Pingback]
Comments are closed.
Navigation
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)