<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Isolation &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/isolation/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 20 Nov 2017 05:40:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-3)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 06 Jun 2016 17:52:37 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DeadLock]]></category>
		<category><![CDATA[interivews]]></category>
		<category><![CDATA[Isolation]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[Lock escalation]]></category>
		<category><![CDATA[locking hints]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[spin lock]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[WITH (NOLOCK)]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2922</guid>

					<description><![CDATA[Database session A tries to update some data that is already locked by database session B. What happens to session A? The session A will actually be placed in what’s called a lock wait state, and session A will be stopped from making further progress with any SQL transaction that it’s performing. Another way of saying [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3%2F&#038;title=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-3%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-locking-hints-escalation-spinlock-day-3/" data-a2a-title="SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-3)"></a></p><p><strong>Database session A tries to update some data that is already locked by database session B. </strong><strong>What happens to session A?</strong></p>
<blockquote><p>The session A will actually be placed in what’s called a lock wait state, and session A will be stopped from making further progress with any SQL transaction that it’s performing. Another way of saying this is that session A will be “stalled” until session B releases the lock on that data.</p></blockquote>
<p><strong>What is lock contention?</strong></p>
<blockquote><p>One problem that occurs with having locks is that locks can cause what’s known as contention.</p>
<p>In the best case, lock contention means that some user processes run slower because a session is waiting for a lock. In the worst case, having sessions compete for locks can make sessions stall for an indefinite period of time.</p></blockquote>
<p><strong>What is Locking Hints option?</strong></p>
<blockquote><p>Locking hints can be specified for individual table references in the SELECT, INSERT, UPDATE, and DELETE statements. The hints specify the type of locking or row versioning the instance of the SQL Server Database Engine uses for the table data.</p></blockquote>
<p><strong>Does Locking hints override the current transaction isolation level?</strong></p>
<blockquote><p>Yes, The Locking hints override the current transaction isolation level for the session.</p></blockquote>
<p><strong>What is WITH (NOLOCK)?</strong></p>
<blockquote><p>It is equivalent to READUNCOMMITTED isolation level and you can SELECT table dirty data which are not yet committed.</p></blockquote>
<p><strong>What is WITH (NOWAIT)?</strong></p>
<blockquote><p>It instructs the Database Engine to return a message as soon as a lock is encountered on the table. NOWAIT is equivalent to specifying SET LOCK_TIMEOUT 0 for a specific table.</p></blockquote>
<p><strong>What is WITH (ROWLOCK)?</strong></p>
<blockquote><p>It specifies that row locks are taken when page or table locks are ordinarily taken.</p></blockquote>
<p><strong>What is WITH (TABLOCK)?</strong></p>
<blockquote><p>Specifies that the acquired lock is applied at the table level. The type of lock that is acquired depends on the statement being executed.</p></blockquote>
<p><strong>What is WITH (UPDLOCK)?</strong></p>
<blockquote><p>It specifies that update locks are to be taken and held until the transaction completes. UPDLOCK takes update locks for read operations only at the row-level or page-level.</p></blockquote>
<p><strong>What is the use of sys.dm_tran_locks?</strong></p>
<blockquote><p>You can query the sys.dm_tran_locks dynamic management view to obtain information about the current state of locking in an instance of the Database Engine.</p></blockquote>
<p><strong>What is a Lock Escalation?</strong></p>
<blockquote><p>A query might have a resource locked for &#8220;shared&#8221; and escalate it to &#8220;exclusive&#8221; to perform an update. SQL Server does Lock Escalation in order to reduce memory overhead, by converting several fine-grained low level locks to coarse-grained high level locks. Page Locks are also escalated to Table Locks.</p></blockquote>
<p><strong>What is the Spinlock?</strong></p>
<blockquote><p>It controls access to a lock resource, such as a row or a table.</p>
<p>Without lock partitioning, one spinlock manages all lock requests for a single lock resource.</p>
<p>To reduce contention on a single lock resource, lock partitioning splits a single lock resource into multiple lock resources to distribute the load across multiple spinlocks.</p></blockquote>
<p><strong>How READ_COMMITTED internally implemented row level locks?</strong></p>
<blockquote><p>When SQL Server executes a statement at the read committed isolation level, it acquires short lived share locks on a row by row basis. The duration of these share locks is just long enough to read and process each row; the server generally releases each lock before proceeding to the next row.</p></blockquote>
<p><strong>Within the REPEATABLE_READ and SERIALIZABLE isolation levels, during a read operation and assuming row-level locking, how long are locks held or retained for?</strong></p>
<blockquote><p>Answer: Within either of these isolation levels, locks are held for the duration of the transaction, unlike within the READ_COMMITTED isolation level.</p></blockquote>
<p><strong>When Lock escalation is triggered?</strong></p>
<blockquote><p>When a single Transact-SQL statement acquires at least 5,000 locks on a single table or index.</p>
<p>When the number of locks in an instance of the Database Engine exceeds memory or configuration thresholds.</p>
<p>If locks cannot be escalated because of lock conflicts, the Database Engine periodically triggers lock escalation at every 1,250 new locks acquired.</p></blockquote>
<p><strong>Name as many of the lockable resources of the SQL Server.</strong></p>
<ul>
<li>RID (single row on a heap)</li>
<li>KEY (single row (or range) on an index)</li>
<li>PAGE</li>
<li>EXTENT</li>
<li>HOBT (heap or b-tree)</li>
<li>TABLE (entire table, all data and indexes)</li>
<li>FILE</li>
<li>APPLICATION</li>
<li>METADATA</li>
<li>ALLOCATION_UNIT</li>
<li>DATABASE</li>
</ul>
<p><strong>What is the least restrictive and the most restrictive type of lock?</strong></p>
<blockquote><p>The least restrictive type of lock is a shared lock. The most restrictive type of lock is a schema-modification.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-2)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 05 Jun 2016 17:55:04 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DeadLock]]></category>
		<category><![CDATA[exclusive lock]]></category>
		<category><![CDATA[intent lock]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[Isolation]]></category>
		<category><![CDATA[live lock]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[lock partitioning]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[schema lock]]></category>
		<category><![CDATA[shared lock]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[update lock]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2919</guid>

					<description><![CDATA[What is the Read Uncommitted Isolation Level of the SQL Server? SQL Server: What is Read Uncommitted Isolation Level? &#160; What is the READ COMMITTED Isolation Level of the SQL Server? SQL Server: READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option &#160; What is the READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option? When the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2%2F&#038;title=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-2%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-shared-update-exclusive-live-schema-intent-lock-day-2/" data-a2a-title="SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-2)"></a></p><p><strong>What is the Read Uncommitted Isolation Level of the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="845OXYLMTN"><p><a href="https://www.dbrnd.com/2016/04/sql-server-what-is-read-uncommitted-isolation-level/">SQL Server: What is Read Uncommitted Isolation Level?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-what-is-read-uncommitted-isolation-level/embed/#?secret=845OXYLMTN" data-secret="845OXYLMTN" width="600" height="338" title="&#8220;SQL Server: What is Read Uncommitted Isolation Level?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>&nbsp;</p>
<p><strong>What is the READ COMMITTED Isolation Level of the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="Acks8yi2wc"><p><a href="https://www.dbrnd.com/2016/04/sql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option/">SQL Server: READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option/embed/#?secret=Acks8yi2wc" data-secret="Acks8yi2wc" width="600" height="338" title="&#8220;SQL Server: READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>&nbsp;</p>
<p><strong>What is the READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option?</strong></p>
<blockquote><p>When the READ_COMMITTED_SNAPSHOT database option is ON, read committed isolation uses row versioning.</p>
<p>READ COMMITTED SNAPSHOT does optimistic reads and pessimistic writes. When data is updating, you can still read old version of data and there is no any share lock, but you cannot update that same data until the running update is not finished.</p></blockquote>
<p><strong>What is the REPEATABLE READ Isolation Level of the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="LqSBNPx9h7"><p><a href="https://www.dbrnd.com/2016/04/sql-server-what-is-repeatable-read-isolation-level/">SQL Server: What is REPEATABLE READ Isolation Level?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-what-is-repeatable-read-isolation-level/embed/#?secret=LqSBNPx9h7" data-secret="LqSBNPx9h7" width="600" height="338" title="&#8220;SQL Server: What is REPEATABLE READ Isolation Level?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>&nbsp;</p>
<p><strong>What is the SERIALIZABLE Isolation level of the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="bgNGRhASFf"><p><a href="https://www.dbrnd.com/2016/04/sql-sever-what-is-serializable-isolation-level/">SQL Sever: What is SERIALIZABLE Isolation level?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-sever-what-is-serializable-isolation-level/embed/#?secret=bgNGRhASFf" data-secret="bgNGRhASFf" width="600" height="338" title="&#8220;SQL Sever: What is SERIALIZABLE Isolation level?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the SNAPSHOT Isolation Level of the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="bvolybPzQT"><p><a href="https://www.dbrnd.com/2016/04/sql-server-what-is-snapshot-isolation-level/">SQL Server: What is SNAPSHOT Isolation Level?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-what-is-snapshot-isolation-level/embed/#?secret=bvolybPzQT" data-secret="bvolybPzQT" width="600" height="338" title="&#8220;SQL Server: What is SNAPSHOT Isolation Level?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>&nbsp;</p>
<p><strong>Can you enable SNAPSHOT Isolation Level for a particular SQL statement?</strong></p>
<blockquote><p>You cannot enable SNAPSHOT Isolation level at statement level.</p>
<p>You have to enable at the database level and after enabling all your database transactions will execute in MVCC fashion.</p></blockquote>
<p><strong>What is the difference between READ_COMMITTED_SNAPSHOT option and Snapshot Isolation Level?</strong></p>
<blockquote><p>Using READ_COMMITTED_SNAPSHOT option, you can SELECT old version of rows while it is updating, but you cannot execute new UPDATE on the same data until it finished a running UPDATE.</p>
<p>Using SNAPSHOT ISOLATION LEVEL, you can perform any kind of DML operation because it is managing different data version in the TempDB so the reader and writer never blocked by each other.</p></blockquote>
<p><strong>What is a Shared lock?</strong></p>
<blockquote><p>Shared (S): Used for read operations that do not change or update data, such as a SELECT statement.</p></blockquote>
<p><strong>What is an Update lock?</strong></p>
<blockquote><p>Update(U): Used on resources that can be updated. Prevents a common form of deadlock that occurs when multiple sessions are reading, locking, and potentially updating resources later.</p></blockquote>
<p><strong>What is an Exclusive lock?</strong></p>
<blockquote><p>Exclusive(X): Used for data-modification operations, such as INSERT, UPDATE, or DELETE. Ensures that multiple updates cannot be made to the same resource at the same time.</p></blockquote>
<p><strong>What is an Intent lock?</strong></p>
<blockquote><p>The Database Engine uses intent locks to protect placing a shared (S) lock or exclusive (X) lock on a resource lower in the lock hierarchy. Intent locks are named intent locks because they are acquired before a lock at the lower level, and therefore signal intent to place locks at a lower level.</p></blockquote>
<p><strong>What is a Schema lock?</strong></p>
<blockquote><p>The Database Engine uses schema modification (Sch-M) locks during a table data definition language (DDL) operation, such as adding a column or dropping a table. During the time that it is held, the Sch-M lock prevents concurrent access to the table.</p></blockquote>
<p><strong>What is a Bulk Update lock?</strong></p>
<blockquote><p>BulkUpdate (BU): Used when bulk copying data into a table and the TABLOCK hint is specified.</p></blockquote>
<p><strong>What is a Key range lock?</strong></p>
<blockquote><p>Key-range locks protect a range of rows implicitly included in a record set being read by a Transact-SQL statement while using the serializable transaction isolation level. Key-range locking prevents phantom reads.</p>
<p>A key range lock protects this requirement by preventing other transactions from inserting new rows whose keys would fall in the range of keys read by the serializable transaction.</p></blockquote>
<p><strong>Do you think lock is reducing the performance of the database system?</strong></p>
<blockquote><p>For large computer systems, locks on frequently referenced objects can become a performance bottleneck as acquiring and releasing locks place contention on internal locking resources.</p></blockquote>
<p><strong>What do you know about the lock partitioning?</strong></p>
<blockquote><p>Lock partitioning enhances locking performance by splitting a single lock resource into multiple lock resources. This feature is only available for systems with 16 or more CPUs, and is automatically enabled and cannot be disabled. Only object locks can be partitioned.</p></blockquote>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option</title>
		<link>https://www.dbrnd.com/2016/04/sql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 01 Apr 2016 20:46:41 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Isolation]]></category>
		<category><![CDATA[Read committed Isolation level]]></category>
		<category><![CDATA[READ_COMMITTED_SNAPSHOT]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2199</guid>

					<description><![CDATA[In this post, I am going to share an important note about the READ COMMITTED isolation level and how it works with the READ_COMMITTED_SNAPSHOT option of SQL Server. The READ COMMITTED is the default isolation level of SQL Server, and it prevents the dirty reads. Your SELECT statements always returns committed data. It issues shared [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&amp;linkname=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option%2F&#038;title=SQL%20Server%3A%20READ%20COMMITTED%20Isolation%20Level%20with%20the%20READ_COMMITTED_SNAPSHOT%20option" data-a2a-url="https://www.dbrnd.com/2016/04/sql-server-read-committed-isolation-level-with-the-read_committed_snapshot-option/" data-a2a-title="SQL Server: READ COMMITTED Isolation Level with the READ_COMMITTED_SNAPSHOT option"></a></p><p><em>In this post, I am going to share an important note about the READ COMMITTED isolation level and how it works with the READ_COMMITTED_SNAPSHOT option of SQL Server.</em></p>
<blockquote><p>The READ COMMITTED is the default isolation level of SQL Server, and it prevents the dirty reads.<br />
Your SELECT statements always returns committed data.</p></blockquote>
<blockquote><p>It issues shared lock against the data where data are updating or having an exclusive lock so for selecting those data you have to wait to complete that transaction. </p></blockquote>
<p><strong>Now test the READ COMMITTED isolation level:</strong></p>
<p><strong>First, create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employee
(
	EmpID INTEGER
	,EmpName VARCHAR(50)
)
GO

INSERT INTO tbl_Employee
VALUES 
(1,'Anvesh'),(2,'Neevan')
,(3,'Roy'),(4,'Martin')
GO</pre> </p>
<p><strong>Open a new query window or session and executing this script:</strong></p>
<pre class="crayon-plain-tag">BEGIN TRANSACTION
	UPDATE tbl_Employee SET EmpName ='Jenny' WHERE EmpID=1
	WAITFOR DELAY '00:00:15'  
COMMIT</pre> </p>
<p><strong>During the delay of 15 seconds, Open a new query window or session and try to SELECT that table:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_Employee</pre>
The result is, you can not SELECT your data until the UPDATE is not completed. As we have set delay of 15 seconds, so you have to wait for 15 seconds.</p>
<p><strong>What is READ_COMMITTED_SNAPSHOT option?</strong></p>
<blockquote><p>
READ COMMITTED isolation level depends on option ON / OFF setting.<br />
It is by default OFF.</p></blockquote>
<blockquote><p><strong>ALTER command to switch it to ON / OFF:</strong></p>
<pre class="crayon-plain-tag">-- Switch to ON
ALTER DATABASE Database_Name SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE

-- Switch to OFF
ALTER DATABASE Database_Name SET READ_COMMITTED_SNAPSHOT OFF WITH ROLLBACK IMMEDIATE</pre>
</p></blockquote>
<blockquote><p><strong>READ_COMMITTED_SNAPSHOT OFF:</strong></p>
<p>This is the default setting and issues the shared locks to prevent other transaction when we are reading or updating a table data.<br />
Above small demonstration represents the behaviour of this default setting.
</p></blockquote>
<blockquote><p><strong>READ_COMMITTED_SNAPSHOT ON:</strong></p>
<p>When the READ_COMMITTED_SNAPSHOT database option is ON, read committed isolation uses row versioning.</p>
<p>READ COMMITTED SNAPSHOT does optimistic reads and pessimistic writes. When data is updating, you can still read the old version of data, and there is no any shared lock, but you cannot update that same data until the running update is not finished. </p>
<p>This is very different than Snapshot Isolation level.<br />
It consumes less tempdb space than snapshot isolation.<br />
In the Snapshot Isolation level, the same data causes an update conflict because two different transactions can update the same version of the row. </p>
</blockquote>
<p><strong>Now, test the READ_COMMITTED_SNAPSHOT ON:</strong></p>
<p><strong>ALTER command to ON a READ_COMMITTED_SNAPSHOT:</strong></p>
<pre class="crayon-plain-tag">ALTER DATABASE Database_Name SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE</pre> </p>
<p><strong>Open a new query window or session and executing below script:</strong></p>
<pre class="crayon-plain-tag">BEGIN TRANSACTION
	UPDATE tbl_Employee SET EmpName ='Jenny' WHERE EmpID=1
	WAITFOR DELAY '00:00:15'  
COMMIT</pre> </p>
<p><strong>During the delay of 15 seconds, Open a new query window or session and try to SELECT this table:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_Employee</pre>
The result is, You can SELECT an old version of the data. </p>
<p><strong>During the delay of 15 seconds, Open a new query window or session and try to UPDATE same row:</strong></p>
<pre class="crayon-plain-tag">UPDATE tbl_Employee SET EmpName ='Jekvlin' WHERE EmpID=1</pre>
The result is, You cannot perform an UPDATE on the same data. </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)</title>
		<link>https://www.dbrnd.com/2015/05/acid-properties-in-database-system/</link>
					<comments>https://www.dbrnd.com/2015/05/acid-properties-in-database-system/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 01 May 2015 11:48:54 +0000</pubDate>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[ACID PropertiesAnvesh Patel]]></category>
		<category><![CDATA[Atomicity]]></category>
		<category><![CDATA[Consistency]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Durability]]></category>
		<category><![CDATA[Isolation]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=14</guid>

					<description><![CDATA[Database ACID Properties: ACID properties are an ancient and valuable concept of database theory. I know that you can find lots of posts about this topic, but still, I would like to start my journey with this subject as one of very important and my favourite theory of Database system. Database System plays with lots [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&amp;linkname=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Facid-properties-in-database-system%2F&#038;title=ACID%20Properties%20in%20Database%20System%20%28Atomicity%2C%20Consistency%2C%20Isolation%2C%20Durability%29" data-a2a-url="https://www.dbrnd.com/2015/05/acid-properties-in-database-system/" data-a2a-title="ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)"></a></p><p><strong><u>Database ACID Properties:</u></strong></p>
<p>ACID properties are an ancient and valuable concept of database theory. I know that you can find lots of posts about this topic, but still, I would like to start my journey with this subject as one of very important and my favourite theory of Database system.</p>
<p>Database System plays with lots of different types of transactions where all transaction has a particular characteristic. This characteristic is known ACID Properties.</p>
<blockquote><p>ACID Properties take grantee for all database transactions to accomplish all tasks.</p></blockquote>
<p><u>Many times interviewers ask this question in an interview that, What is ACID Property in database?</u></p>
<p>Here I am going to explain with a simple example.</p>
<p>A = Atomicity</p>
<p>C = Consistency</p>
<p>I = Isolation</p>
<p>D = Durability</p>
<p><strong>First, </strong></p>
<p><strong>Atomicity:</strong> means either all or none, for example,</p>
<blockquote><p>One Application is going to insert 30 records in one transaction. During this insertion, any problem occurs, and at this point, only 12 records have processed. In this state transaction is not going to insert only 12 records it will roll back this whole transaction, so this will process either all or none.</p></blockquote>
<p><strong>Consistency:</strong> means to bring database from one valid state to another valid state. </p>
<blockquote><p>There should be always defined some data rule, constraint, trigger at database end as well as application end.</p>
<p>Whatever data is going to insert they all should be validated by setting rules and ensure that there are no invalid data is going to insert in the database so this way it will manage consistency of the database.<br />
In any case running transaction violate rule at that same time entire transaction will be rollback.</p></blockquote>
<p><strong>Isolation:</strong> means each transaction is unaware of another transaction.</p>
<blockquote><p>One shop seller is selling items very fast, and the stock is also decreasing. At the same time, another person is also adding a new item in the stock. </p>
<p>Here, this both transactions is different and unaware of each other. </p>
<p>Isolation level ensures that one transaction is not interrupted by another transaction. </p>
<p>For database transaction, this one of the important properties because any database system is going with lots of concurrent and parallel transactions where Isolation property is very much required and ensure that all transactions are defined under proper isolation level. </p>
<p>A different database technology has different type of default Isolation level like,</p>
<p>Oracle has READ_COMMITTED</p>
<p>MySQL has REPETABLE_READ</p>
<p>MSSQL has READ_COMMITTED</p>
<p>PostgreSQL has READ_COMMITTED</p>
<p>DB2 has READ_COMMITTED</p>
<p>Read_committed Isolation level is most preferable, but many times it&#8217;s also required to show READ_UNCOMMITTED data in a data history kind of pages.</p></blockquote>
<p><strong>Durability:</strong> means to keep committed data forever.</p>
<blockquote><p>Application inserted 30 records in one transaction, and this transaction is completed and committed successfully in the database that means records persist forever in the database until and unless it&#8217;s not deleted by any application users or database users.</p>
</blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/05/acid-properties-in-database-system/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
	</channel>
</rss>
