SQL Server Concurrency issue -
i’ve report sits on top of view. view underlying tables updated every 15 minutes , update cycle takes approximately 1 -2 minutes , during time if run report i’m getting wrong values on report .is there way can apply kind of locks on view can report once update done , avoid dirty data on report.please let me know if there other solution issue
thanks, ravi
i consider using different method update underlying tables. instead of updating these tables 1-2 minutes, make "shadow" tables in schema. (and have third schema temporary holding.) allows work on tables users can't see, switch them in using metadata operation. can this:
- truncate/re-populate shadow tables (2 minutes, or maybe less no contention)
- start transaction (sub-millisecond)
- move primary table holding schema, using alter schema ... transfer (sub-millisecond)
- move shadow table dbo schema (sub-millisecond)
- move primary table shadow schema (sub-millisecond)
- commit transaction (sub-millisecond)
- (optional) truncate shadow table recover space (sub-second)
one downside of solution have 2 sets of stats, indexes etc. maintain. stats should ok if data increasing , not changing substantially otherwise.
adam haines has thorough write-up method (which showed him few years ago) here:
http://jahaines.blogspot.com/2009/10/locking-table-while-it-is-being-loaded.html
Comments
Post a Comment