{"id":1412,"date":"2012-10-02T00:00:00","date_gmt":"2012-10-02T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/sql-server-concurrency-locking-blocking-and-row-versioning\/"},"modified":"2024-08-30T12:49:26","modified_gmt":"2024-08-30T12:49:26","slug":"sql-server-concurrency-locking-blocking-and-row-versioning","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/resources\/books\/simple-talk-published-books\/sql-server-concurrency-locking-blocking-and-row-versioning\/","title":{"rendered":"SQL Server Concurrency: Locking, Blocking and Row Versioning"},"content":{"rendered":"<div id=\"pretty\">  <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/1569-SQL_Server_Concurrency_COVERx200.gif\" class=\"float-left\" alt=\"1569-SQL_Server_Concurrency_COVERx200.gi\" \/><\/p>\n<p> <strong>Free PDF:<\/strong> <a href=\"http:\/\/www.red-gate.com\/products\/dba\/sql-monitor\/entrypage\/sql-server-concurrency-ebook?utm_source=simpletalk&amp;utm_medium=weblink&amp;utm_content=concurrency_ebook&amp;utm_campaign=sqlmonitor\">From Red Gate<\/a><br \/><strong>Buy the printed book:<\/strong> <a href=\"http:\/\/www.amazon.com\/gp\/product\/1906434913\/\">US<\/a> $29.99 | <a href=\"http:\/\/www.amazon.co.uk\/SQL-Server-Concurrency-Kalen-Delaney\/dp\/1906434913\/\">UK<\/a> &#194;&#163;19.99<br \/><strong>Kindle edition:<\/strong> <a href=\"http:\/\/www.amazon.com\/SQL-Server-Concurrency-Versioning-ebook\/dp\/B00CZ1BVGY\/\">US<\/a> $10.26 | <a href=\"http:\/\/www.amazon.co.uk\/SQL-Server-Concurrency-Versioning-ebook\/dp\/B00CZ1BVGY\/\">UK<\/a> &#194;&#163;6.79 <\/p>\n<p class=\"start\">Your application can have impeachable indexes and queries, but they won&#8217;t help you if you can&#8217;t get to your data because another application has it locked. That&#8217;s why every DBA and developer must understand SQL Server concurrency and how to troubleshoot excessive blocking or deadlocking.<\/p>\n<p>If you&#8217;ve designed your SQL code intelligently and implemented a sensible indexing strategy, there&#8217;s a good chance your queries will &#8220;fly&#8221;, when tested in isolation. In the real world, however, where multiple processes can access the same data at the same time, SQL Server often has to make one process wait, sacrificing <strong>concurrency<\/strong> and <strong>performance<\/strong> in order that all processes can succeed without destroying data integrity.<\/p>\n<p><strong>Transactions<\/strong> are<strong> <\/strong>at the heart of concurrency. I explain their ACID properties, the transaction isolation levels that dictate acceptable behaviors when multiple transactions access the same data simultaneously, and SQL Server&#8217;s <strong>optimistic<\/strong> and <strong>pessimistic<\/strong> models for mediating concurrent access.<\/p>\n<p><strong>Pessimistic concurrency<\/strong>, SQL Server&#8217;s default, uses <strong>locks<\/strong> to avoid concurrency problems. I explain all the different locks and their compatibility. I show how to control locking with hints and bound connections, and how to troubleshoot excessive blocking and deadlocking.<\/p>\n<p><strong>Optimistic concurrency<\/strong> uses row versions to support concurrency. I explain how row versioning works, cover SQL Server&#8217;s two snapshot-based isolation levels and offer troubleshooting tips for issues such as update conflicts.<\/p>\n<p>Your application can have world-class indexes and queries, but they won&#8217;t help you if you can&#8217;t get your data because another application has it locked. That&#8217;s why every DBA and developer must understand SQL Server concurrency, and how to troubleshoot any issues. I hope my book helps!<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Your application can have impeachable indexes and queries, but they won&#8217;t help you if you can&#8217;t get to your data because another application has it locked. That&#8217;s why every DBA and developer must understand SQL Server concurrency and how to troubleshoot excessive blocking or deadlocking. Kalen Delaney&#8217;s book is your guide.&hellip;<\/p>\n","protected":false},"author":104640,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[159158],"tags":[4728,4363,5723,4179,4150,5013,4151],"coauthors":[48699],"class_list":["post-1412","post","type-post","status-publish","format-standard","hentry","category-simple-talk-published-books","tag-blocking","tag-books","tag-concurrency","tag-source-control","tag-sql","tag-sql-books","tag-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/104640"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1412\/revisions"}],"predecessor-version":[{"id":103791,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1412\/revisions\/103791"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=1412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=1412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=1412"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}