SlideShare a Scribd company logo
1 of 25
 Concurrency and Transactions
 Locking Basics
 Advanced Locking Concepts
 Controlling Locking
 Troubleshooting Pessimistic Concurrency
 Optimistic Concurrency
 Introduction of Concurrency
We can define concurrency as the ability of multiple sessions to access or change
shared data, at the same time.
Introduction of Concurrency
• The greater the number of concurrent processes that can be active without
interfering with each other, the greater the concurrency of the database
system and the more scalable the system will be.
High Concurrency
Low Concurrency
• Concurrency is reduced when a session that is changing data prevents other
processes from reading that data.
• When a session that is reading data prevents other sessions from changing that
data.
Introduction of Concurrency
Current Concurrency Models Supported by SQL Server Database
• Pessimistic(Default)
• Optimistic
 Pessimistic concurrency avoids conflicts by acquiring locks on data that is
being read, so no other processes can modify that data.
 For example, when querying data into a form, for subsequent modification,
the application logic should store the original values and then check them
against the values that exist at the point the modification is issued.
 It also acquires locks on data being modified, so no other processes can access
that data for either reading or modifying.
 In other words, readers block writers and writers block readers in a pessimistic
concurrency environment.
 A programmer will need to enforce optimistic concurrency by the use of
intelligent programming techniques.
 If they are different, logic must exist to resolve this conflict and/or handle any
error raised.
Concurrency and Transactions
• The ANSI SQL Standard defines three phenomena (dirty reads, non-repeatable reads and
phantom reads), which can be allowed or prevented, depending on the ANSI-standard
transaction isolation level in use: READ UNCOMMITTED, READ COMMITTED(the default),
REPEATABLE READ, or SERIALIZABLE
Preventable read phenomena
Lost updates
• One session accidentally overwrites modifications performed by another.
Excessive blocking
• A "queue" of blocked processes forms, causing pressure on the resource and
unacceptable delays to end-users
• Mutual blocking between sessions such that further progress is
impossible.
Transaction
Deadlocks
• a transaction is that it is a single unit of work; a task or set of tasks that
together form an "all-or-nothing" operation.
• Atomicity– A transaction is treated as a single unit of work. Either it completes
entirely, or the system has no "memory" of it happening at all. This applies to transactions
of any size, whether two rows are being inserted, or 10 million rows are being updated.
• Consistency– A transaction will leave data in a meaningful state when it completes. In
a relational database, all constraints will be applied to the transaction's modifications to
maintain data integrity. Internal data structures, such as the trees and linked lists used for
maintaining indexes, will be correct at the end of a transaction. A transaction cannot
leave data in a state that violates uniqueness or referential integrity.
• Isolation– The changes that one transaction makes should not interfere with the
changes that another transaction makes; each transaction should be executed as if it were
the only work that the database system was performing.
• Durability– Once a transaction completes, its effects are permanent and recoverable.
If the system shuts down, either intentionally or because of a system crash, any time after
a transaction was completed (or committed) then, when the system starts again, the
changes made by completed transactions are available.
Concurrency and Transactions
However, by default, SQL Server guarantees only three out of the four:
atomicity, consistency and durability.
Transactions have four basic properties
• auto-commit transactions– An auto-commit transaction is any single data
modification operation. In other words, any INSERT, UPDATE or DELETE statement (as well
as others, such as MERGE and BULK INSERT), by itself, is automatically a transaction.
• explicit transactions– An explicit transaction uses the BEGIN TRANSACTION(or BEGIN
TRAN) statement to indicate the beginning of the transaction, and either a COMMIT
TRANSACTION or a ROLLBACK TRANSACTION statement to indicate the end. In between,
the transaction can include any number of statements.
• implicit transactions – implicit transactions, a session must be in implicit transaction
mode, invoked with a SET option: SET IMPLICIT_TRANSACTIONS ON. In implicit
transaction mode, the start of any transaction is implied.
Although, in this mode, the start of the transaction is implied, the
end of the transaction must be explicit, and the transaction is not finished until we issue
either a ROLLBACK TRAN or COMMIT TRAN.
Concurrency and Transactions
Transaction scope
The default types of transactions are auto-commit transactions and explicit
transactions. The non-default types of transactions are implicit transactions and
batch-scoped transactions.
• batch-scoped transactions– we invoke batch-scoped transactions by requesting the
option Multiple Active Result Sets(or MARS) in the client connection string. In those
connections, SQL Server will roll back any batch that includes a BEGIN TRAN but does not
include a COMMIT TRAN. The purpose of MARS is to avoid a problem called "application
deadlock,"
Concurrency and Transactions
Transaction scope
Transactions isolation levels
• READ UNCOMMITTED– allows dirty reads, non-repeatable reads and phantom reads
• READ COMMITTED– prevents dirty reads, allows non-repeatable reads and phantom
reads
• REPEATABLE READ– prevents dirty reads and non-repeatable reads but allows phantom
reads and doesn't allow another process to update values the first one has read.
• SERIALIZABLE– prevents all read phenomena.
Every transaction runs in one particular transaction isolation level, which
determines how sensitive your application is to changes made by other users'
transactions, and how long SQL Server must hold locks to protect against these
changes.
The ANSI SQL standard defines four levels of isolation for transactions.
• With the exception of READ UNCOMMITTED, each of these isolations levels is
pessimistic in nature. In other words, when transactions are operating in one of these
modes, SQL Server will acquire shared and exclusive locks in order to prevent data being
read that is currently being modified by another transaction, and to prevent other
transactions modifying data that is currently being read.
• In addition, SQL Server 2005 (and later) offers a new optimistic isolation level, called
SNAPSHOT isolation, plus an optimistic alternative to READ COMMITTED isolation
(READ_COMMITTED_SNAPSHOT), both of which can ensure consistent results without
the need to acquire shared locks, and so can enhance concurrency.
SQL Server's default isolation level is READ COMMITTED
Preventable read phenomena
• Dirty reads
 when a transaction reads uncommitted data.
If one transaction has changed data but not committed the change, and
another transaction is allowed to read that changed data, then there is
a strong possibility that the data will be read in an inconsistent state
 SQL Server does not allow dirty reads.
 the transaction updating the data has no control over whether or not
another transaction can read its data before it's committed.
 The decision regarding whether or not to read "dirty" data lies entirely in
the hands of the reading transaction.
• Non-repeatable reads
 This behavior is also called inconsistent analysis.
 A read is non-repeatable if a query might get different values when reading
the same data in two separate reads within the same transaction.
 This can happen when a separate transaction updates the same data, after
the first read but before the second read.
• Phantom reads.
 A phantom occurs if two SELECT operations using the same predicate in the
same transaction return a different number of rows.
Design Consideration of Pessimistic Concurrency Model
 While preventing blocking, by selecting the READ UNCOMMITTED level, might seem
attractive from a concurrency perspective, the price to pay is the prospect of reading
incorrect data.
 At the same time, while preventing all read phenomena, and so guaranteeing more
consistent data, is a "good thing," be aware of the tradeoffs in setting your isolation
level too high, which is the added cost of acquiring and managing locks, and blocking
other processes while those locks are held.
Locking Basics
 Locking is the activity that occurs when a SQL Server session takes "ownership" of a
resource prior to performing a particular action on that resource, such as reading or
updating it.
 SQL Server makes all locking decisions internally and will usually make the best choices.
 If we write code in such a way that it forces SQL Server to acquire a very large number of
locks, or to hold them for unnecessarily long periods, then
 this will cause resource contention in the database,
 other users' transactions will be blocked from accessing the data they need,
 the performance of these blocked transactions will be affected.
 The unit of data locked (lock resource) – such as row, page, or table
 The type of locks acquired (lock mode) – shared, exclusive, update, and so on
 The duration of the lock – how long the lock is held
 Lock ownership – the "scope" of the lock (most locks are transaction scoped)
 Lock metadata – how to review current locking using the Dynamic Management
 Fundamental aspects of this locking mechanism:
Lock Resources
 SQL Server can lock user data resources at the row, page, or table level
 SQL Server will attempt to acquire row-level locks, to allow the highest degree of
concurrency.
 SQL Server to acquire locks on larger units of data either initially, or through a process of
"lock escalation."
 When SQL Server locks a row in an index,
 it refers to it, and displays it, as a KEY lock,
 SQL Server locks the entire index row, not just the key column.
 SQL Server can also lock ranges of index rows called key-range locks
 Key-range locks are not perfect, but they do give much greater concurrency than locking
a whole page or the entire table.
 A key-range lock implies a locked range of index rows including all values greater than
the value of the index key that precedes the locked row, and ends with the locked row.
Lock Resources
 When SQL Server Locks on rows in a heap table (one without a clustered index) ,it might
acquire KEY locks for the non-clustered index rows and RID locks for the data rows.
 If there is no index on the column specifying the range (i.e LastName), SQL Server would
acquire row or page locks, even in recent versions.
For example, suppose we have an index on the lastname column in the Employees table. A
transaction, shown below, is running under the SERIALIZABLE isolation level, and reads a
range of rows in the Employees table.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRAN
SELECT *
FROM Employees
WHERE LastName BETWEEN 'MacDougal' AND 'McDougall'
No one should be able to insert a row with McDonald, but a row with Mabry would be
fine.
Lock Modes
 Shared locks,
 Exclusive locks, and
 Update locks
The lock mode specifes how restrictive the lock is and what other actions are possible while
the lock is held.
SQL Server uses following lock modes to achieve the four required ANSI modes of
transaction isolation.
Shared locks
 By default, SQL Server acquires shared (S) locks automatically when it reads data.
 A table, page, or individual row of a table or index can hold an S lock.
 In addition, to support SERIALIZABLE transaction isolation, SQL Server can place S locks
on a range of index rows.
 SQL Server releases S locks as soon as it has finished reading the data.
 However, use of a higher transaction isolation level, either REPEATABLE READ or
SERIALIZABLE, changes this behavior, so that SQL Server holds S locks until the end of
the transaction.
 As the name implies, many processes can hold S locks on the same data, but no process
can acquire an exclusive lock on data that has an S lock on it
Exclusive locks
 SQL Server automatically acquires exclusive (X) locks on data in order to modify that
data, during an INSERT, UPDATE, or DELETE operation.
 Only one transaction at a time can hold an X lock on a particular data resource, and X
locks remain until the end of the transaction.
 The changed data is usually unavailable to any other process until the trans-action
holding the lock either commits or rolls back.
 However, if a transaction uses the READ UNCOMMITTED transaction isolation level, it
can read data exclusively locked by another transaction.
Update locks
 Update (U) locks are not really a separate kind of lock, but rather a hybrid of S and X
locks.
 A transaction acquires a U lock when SQL Server executes a data modification operation,
but first needs to perform a search to find the resource (for example, the row of data) to
modify.
 SQL Server doesn't need to place an X lock on the row until it is ready to perform the
modification, but it does need to apply some sort of lock as it searches, to protect that
same data from modification by another transaction in the time between finding the
data and modifying it. Therefore, SQL Server places a U lock on the row, checks the row
and, if it meets the criteria, converts it to an X lock.
Intent locks
 An intent lock is used on a "higher" level object to indicate that a lock (one of the types
of locks described) is being taken within that object.
 We can have intent shared (IS) locks, intent exclusive locks (IX), and even intent update
locks (IU)
 For example, a transaction that holds an X lock on a row in the Customers table will also
hold IX locks on both the page containing that row, and the Customers table
 These Intent locks will prevent another transaction from locking the entire Customers
table (acquiring an X lock on the table).
 Whenever a transaction acquires a lock at a lower level of granularity, it also acquires
higher-level intent locks for the same object.
Lock duration
 The length of time that SQL Server holds a lock depends primarily on the mode of the lock
and the transaction isolation level that is in effect.
READ COMMITTED
 SQL Server releases S locks as soon as it has read and processed the locked data.
 It holds an X lock until the end of the transaction, whether the transaction is
committed or rolled back.
 It holds a U lock until the end of the transaction, unless it promoted the U lock to an
X lock, in which case the X lock, as with all X locks, remains for the duration of the
transaction.
REPEATABLE READ or SERIALIZABLE
 S locks have the same duration as X locks.
 That is, SQL Server does not release them until the trans-action is over.
 In addition to changing the transaction isolation level, we can control the lock duration by
using lock hints.
Lock ownership
 Lock duration is directly affected by lock ownership
 Ownership == scope of the lock
Four types of lock scopes
 Transactions – Durations depend on
isolation level and lock mode (shared locks
and update/exclusive locks)
 SHARED_TRANSACTION_WORKSPACE – Every connection in any database (other
than master or tempdb) acquires a lock with this owner by. By observing these
locks, SQL Server can tell when a database is in use.
SHARED_TRANSACTION_WORKSPACE locks are held as long as a connection is
using a database.
 EXCLUSIVE_TRANSACTION_WORKSPACE – SQL Server acquires a lock with this owner
whenever it needs exclusive access to the database. This includes activities such as
dropping the database, restoring the database, or changing certain database
properties, such as the READ_ONLY status.
 Cursors – requested explicitly when a cursor is declared. If a cursor is opened using
a locking mode of SCROLL_LOCKS, a cursor lock is held on every row fetched until
the next row is fetched or the cursor is closed. Even if the transaction commits
before the next fetch, the cursor lock is not released
Mahabubur Rahaman
Senior Database Architect
Orion Informatics Ltd

More Related Content

What's hot (20)

Transactions in dbms
Transactions in dbmsTransactions in dbms
Transactions in dbms
 
Triggers
TriggersTriggers
Triggers
 
Postgresql
PostgresqlPostgresql
Postgresql
 
Database keys
Database keysDatabase keys
Database keys
 
Super Keyword in Java.pptx
Super Keyword in Java.pptxSuper Keyword in Java.pptx
Super Keyword in Java.pptx
 
Sql select
Sql select Sql select
Sql select
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
Relational algebra in DBMS
Relational algebra in DBMSRelational algebra in DBMS
Relational algebra in DBMS
 
Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Trigger
TriggerTrigger
Trigger
 
MySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs AcademyMySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs Academy
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
 
JDBC
JDBCJDBC
JDBC
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Database Security, Threats & Countermeasures.pptx
Database Security, Threats & Countermeasures.pptxDatabase Security, Threats & Countermeasures.pptx
Database Security, Threats & Countermeasures.pptx
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 

Similar to Sql server concurrency

Transaction conccurency
Transaction conccurencyTransaction conccurency
Transaction conccurencyEsraa Farrag
 
Transaction management
Transaction managementTransaction management
Transaction managementArchanaMani2
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesMeghaj Mallick
 
Concurrency Control in Distributed Systems.pptx
Concurrency Control in Distributed Systems.pptxConcurrency Control in Distributed Systems.pptx
Concurrency Control in Distributed Systems.pptxMArshad35
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12Syed Asrarali
 
Locking and concurrency
Locking and concurrencyLocking and concurrency
Locking and concurrencyRumeysaDinsoy
 
Optimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed SystemsOptimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed Systemsmridul mishra
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on TransactionRahul Prajapati
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlkansel85
 
Database consistency in NonStop SQL/MX
Database consistency in NonStop SQL/MXDatabase consistency in NonStop SQL/MX
Database consistency in NonStop SQL/MXFrans Jongma
 
Svetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov
 
Acid Properties In Database Management System
Acid Properties In Database Management SystemAcid Properties In Database Management System
Acid Properties In Database Management SystemAshish Kumar
 

Similar to Sql server concurrency (20)

Dbms voc 5 unit
Dbms voc 5 unitDbms voc 5 unit
Dbms voc 5 unit
 
Transaction conccurency
Transaction conccurencyTransaction conccurency
Transaction conccurency
 
chp13.pdf
chp13.pdfchp13.pdf
chp13.pdf
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed Databases
 
Concurrency Control in Distributed Systems.pptx
Concurrency Control in Distributed Systems.pptxConcurrency Control in Distributed Systems.pptx
Concurrency Control in Distributed Systems.pptx
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Locking and concurrency
Locking and concurrencyLocking and concurrency
Locking and concurrency
 
Chapter 4 u
Chapter 4 uChapter 4 u
Chapter 4 u
 
Optimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed SystemsOptimistic concurrency control in Distributed Systems
Optimistic concurrency control in Distributed Systems
 
Vani dbms
Vani dbmsVani dbms
Vani dbms
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on Transaction
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Database consistency in NonStop SQL/MX
Database consistency in NonStop SQL/MXDatabase consistency in NonStop SQL/MX
Database consistency in NonStop SQL/MX
 
Svetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database Transactions
 
Acid Properties In Database Management System
Acid Properties In Database Management SystemAcid Properties In Database Management System
Acid Properties In Database Management System
 
Process coordination
Process coordinationProcess coordination
Process coordination
 
Lecture 5 inter process communication
Lecture 5 inter process communicationLecture 5 inter process communication
Lecture 5 inter process communication
 

More from Mahabubur Rahaman

Transaction isolationexamples
Transaction isolationexamplesTransaction isolationexamples
Transaction isolationexamplesMahabubur Rahaman
 
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentationsupporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentationMahabubur Rahaman
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tableMahabubur Rahaman
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexingMahabubur Rahaman
 
Introduction to Apache Hadoop Ecosystem
Introduction to Apache Hadoop EcosystemIntroduction to Apache Hadoop Ecosystem
Introduction to Apache Hadoop EcosystemMahabubur Rahaman
 

More from Mahabubur Rahaman (6)

Transaction isolationexamples
Transaction isolationexamplesTransaction isolationexamples
Transaction isolationexamples
 
Lock basicsexamples
Lock basicsexamplesLock basicsexamples
Lock basicsexamples
 
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentationsupporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Introduction to Apache Hadoop Ecosystem
Introduction to Apache Hadoop EcosystemIntroduction to Apache Hadoop Ecosystem
Introduction to Apache Hadoop Ecosystem
 

Recently uploaded

Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...gajnagarg
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...amitlee9823
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...amitlee9823
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...amitlee9823
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachBoston Institute of Analytics
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...gajnagarg
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...amitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...amitlee9823
 

Recently uploaded (20)

Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning Approach
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls Palakkad Escorts ☎️9352988975 Two shot with one girl...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 

Sql server concurrency

  • 1.
  • 2.  Concurrency and Transactions  Locking Basics  Advanced Locking Concepts  Controlling Locking  Troubleshooting Pessimistic Concurrency  Optimistic Concurrency  Introduction of Concurrency
  • 3. We can define concurrency as the ability of multiple sessions to access or change shared data, at the same time. Introduction of Concurrency • The greater the number of concurrent processes that can be active without interfering with each other, the greater the concurrency of the database system and the more scalable the system will be. High Concurrency Low Concurrency • Concurrency is reduced when a session that is changing data prevents other processes from reading that data. • When a session that is reading data prevents other sessions from changing that data.
  • 4. Introduction of Concurrency Current Concurrency Models Supported by SQL Server Database • Pessimistic(Default) • Optimistic  Pessimistic concurrency avoids conflicts by acquiring locks on data that is being read, so no other processes can modify that data.  For example, when querying data into a form, for subsequent modification, the application logic should store the original values and then check them against the values that exist at the point the modification is issued.  It also acquires locks on data being modified, so no other processes can access that data for either reading or modifying.  In other words, readers block writers and writers block readers in a pessimistic concurrency environment.  A programmer will need to enforce optimistic concurrency by the use of intelligent programming techniques.  If they are different, logic must exist to resolve this conflict and/or handle any error raised.
  • 5. Concurrency and Transactions • The ANSI SQL Standard defines three phenomena (dirty reads, non-repeatable reads and phantom reads), which can be allowed or prevented, depending on the ANSI-standard transaction isolation level in use: READ UNCOMMITTED, READ COMMITTED(the default), REPEATABLE READ, or SERIALIZABLE Preventable read phenomena Lost updates • One session accidentally overwrites modifications performed by another. Excessive blocking • A "queue" of blocked processes forms, causing pressure on the resource and unacceptable delays to end-users • Mutual blocking between sessions such that further progress is impossible. Transaction Deadlocks • a transaction is that it is a single unit of work; a task or set of tasks that together form an "all-or-nothing" operation.
  • 6. • Atomicity– A transaction is treated as a single unit of work. Either it completes entirely, or the system has no "memory" of it happening at all. This applies to transactions of any size, whether two rows are being inserted, or 10 million rows are being updated. • Consistency– A transaction will leave data in a meaningful state when it completes. In a relational database, all constraints will be applied to the transaction's modifications to maintain data integrity. Internal data structures, such as the trees and linked lists used for maintaining indexes, will be correct at the end of a transaction. A transaction cannot leave data in a state that violates uniqueness or referential integrity. • Isolation– The changes that one transaction makes should not interfere with the changes that another transaction makes; each transaction should be executed as if it were the only work that the database system was performing. • Durability– Once a transaction completes, its effects are permanent and recoverable. If the system shuts down, either intentionally or because of a system crash, any time after a transaction was completed (or committed) then, when the system starts again, the changes made by completed transactions are available. Concurrency and Transactions However, by default, SQL Server guarantees only three out of the four: atomicity, consistency and durability. Transactions have four basic properties
  • 7. • auto-commit transactions– An auto-commit transaction is any single data modification operation. In other words, any INSERT, UPDATE or DELETE statement (as well as others, such as MERGE and BULK INSERT), by itself, is automatically a transaction. • explicit transactions– An explicit transaction uses the BEGIN TRANSACTION(or BEGIN TRAN) statement to indicate the beginning of the transaction, and either a COMMIT TRANSACTION or a ROLLBACK TRANSACTION statement to indicate the end. In between, the transaction can include any number of statements. • implicit transactions – implicit transactions, a session must be in implicit transaction mode, invoked with a SET option: SET IMPLICIT_TRANSACTIONS ON. In implicit transaction mode, the start of any transaction is implied. Although, in this mode, the start of the transaction is implied, the end of the transaction must be explicit, and the transaction is not finished until we issue either a ROLLBACK TRAN or COMMIT TRAN. Concurrency and Transactions Transaction scope The default types of transactions are auto-commit transactions and explicit transactions. The non-default types of transactions are implicit transactions and batch-scoped transactions.
  • 8. • batch-scoped transactions– we invoke batch-scoped transactions by requesting the option Multiple Active Result Sets(or MARS) in the client connection string. In those connections, SQL Server will roll back any batch that includes a BEGIN TRAN but does not include a COMMIT TRAN. The purpose of MARS is to avoid a problem called "application deadlock," Concurrency and Transactions Transaction scope
  • 9. Transactions isolation levels • READ UNCOMMITTED– allows dirty reads, non-repeatable reads and phantom reads • READ COMMITTED– prevents dirty reads, allows non-repeatable reads and phantom reads • REPEATABLE READ– prevents dirty reads and non-repeatable reads but allows phantom reads and doesn't allow another process to update values the first one has read. • SERIALIZABLE– prevents all read phenomena. Every transaction runs in one particular transaction isolation level, which determines how sensitive your application is to changes made by other users' transactions, and how long SQL Server must hold locks to protect against these changes. The ANSI SQL standard defines four levels of isolation for transactions. • With the exception of READ UNCOMMITTED, each of these isolations levels is pessimistic in nature. In other words, when transactions are operating in one of these modes, SQL Server will acquire shared and exclusive locks in order to prevent data being read that is currently being modified by another transaction, and to prevent other transactions modifying data that is currently being read. • In addition, SQL Server 2005 (and later) offers a new optimistic isolation level, called SNAPSHOT isolation, plus an optimistic alternative to READ COMMITTED isolation (READ_COMMITTED_SNAPSHOT), both of which can ensure consistent results without the need to acquire shared locks, and so can enhance concurrency. SQL Server's default isolation level is READ COMMITTED
  • 10. Preventable read phenomena • Dirty reads  when a transaction reads uncommitted data. If one transaction has changed data but not committed the change, and another transaction is allowed to read that changed data, then there is a strong possibility that the data will be read in an inconsistent state  SQL Server does not allow dirty reads.  the transaction updating the data has no control over whether or not another transaction can read its data before it's committed.  The decision regarding whether or not to read "dirty" data lies entirely in the hands of the reading transaction. • Non-repeatable reads  This behavior is also called inconsistent analysis.  A read is non-repeatable if a query might get different values when reading the same data in two separate reads within the same transaction.  This can happen when a separate transaction updates the same data, after the first read but before the second read. • Phantom reads.  A phantom occurs if two SELECT operations using the same predicate in the same transaction return a different number of rows.
  • 11. Design Consideration of Pessimistic Concurrency Model  While preventing blocking, by selecting the READ UNCOMMITTED level, might seem attractive from a concurrency perspective, the price to pay is the prospect of reading incorrect data.  At the same time, while preventing all read phenomena, and so guaranteeing more consistent data, is a "good thing," be aware of the tradeoffs in setting your isolation level too high, which is the added cost of acquiring and managing locks, and blocking other processes while those locks are held.
  • 12.
  • 13. Locking Basics  Locking is the activity that occurs when a SQL Server session takes "ownership" of a resource prior to performing a particular action on that resource, such as reading or updating it.  SQL Server makes all locking decisions internally and will usually make the best choices.  If we write code in such a way that it forces SQL Server to acquire a very large number of locks, or to hold them for unnecessarily long periods, then  this will cause resource contention in the database,  other users' transactions will be blocked from accessing the data they need,  the performance of these blocked transactions will be affected.  The unit of data locked (lock resource) – such as row, page, or table  The type of locks acquired (lock mode) – shared, exclusive, update, and so on  The duration of the lock – how long the lock is held  Lock ownership – the "scope" of the lock (most locks are transaction scoped)  Lock metadata – how to review current locking using the Dynamic Management  Fundamental aspects of this locking mechanism:
  • 14. Lock Resources  SQL Server can lock user data resources at the row, page, or table level  SQL Server will attempt to acquire row-level locks, to allow the highest degree of concurrency.  SQL Server to acquire locks on larger units of data either initially, or through a process of "lock escalation."  When SQL Server locks a row in an index,  it refers to it, and displays it, as a KEY lock,  SQL Server locks the entire index row, not just the key column.  SQL Server can also lock ranges of index rows called key-range locks  Key-range locks are not perfect, but they do give much greater concurrency than locking a whole page or the entire table.  A key-range lock implies a locked range of index rows including all values greater than the value of the index key that precedes the locked row, and ends with the locked row.
  • 15. Lock Resources  When SQL Server Locks on rows in a heap table (one without a clustered index) ,it might acquire KEY locks for the non-clustered index rows and RID locks for the data rows.  If there is no index on the column specifying the range (i.e LastName), SQL Server would acquire row or page locks, even in recent versions. For example, suppose we have an index on the lastname column in the Employees table. A transaction, shown below, is running under the SERIALIZABLE isolation level, and reads a range of rows in the Employees table. SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; BEGIN TRAN SELECT * FROM Employees WHERE LastName BETWEEN 'MacDougal' AND 'McDougall' No one should be able to insert a row with McDonald, but a row with Mabry would be fine.
  • 16. Lock Modes  Shared locks,  Exclusive locks, and  Update locks The lock mode specifes how restrictive the lock is and what other actions are possible while the lock is held. SQL Server uses following lock modes to achieve the four required ANSI modes of transaction isolation.
  • 17. Shared locks  By default, SQL Server acquires shared (S) locks automatically when it reads data.  A table, page, or individual row of a table or index can hold an S lock.  In addition, to support SERIALIZABLE transaction isolation, SQL Server can place S locks on a range of index rows.  SQL Server releases S locks as soon as it has finished reading the data.  However, use of a higher transaction isolation level, either REPEATABLE READ or SERIALIZABLE, changes this behavior, so that SQL Server holds S locks until the end of the transaction.  As the name implies, many processes can hold S locks on the same data, but no process can acquire an exclusive lock on data that has an S lock on it
  • 18. Exclusive locks  SQL Server automatically acquires exclusive (X) locks on data in order to modify that data, during an INSERT, UPDATE, or DELETE operation.  Only one transaction at a time can hold an X lock on a particular data resource, and X locks remain until the end of the transaction.  The changed data is usually unavailable to any other process until the trans-action holding the lock either commits or rolls back.  However, if a transaction uses the READ UNCOMMITTED transaction isolation level, it can read data exclusively locked by another transaction.
  • 19. Update locks  Update (U) locks are not really a separate kind of lock, but rather a hybrid of S and X locks.  A transaction acquires a U lock when SQL Server executes a data modification operation, but first needs to perform a search to find the resource (for example, the row of data) to modify.  SQL Server doesn't need to place an X lock on the row until it is ready to perform the modification, but it does need to apply some sort of lock as it searches, to protect that same data from modification by another transaction in the time between finding the data and modifying it. Therefore, SQL Server places a U lock on the row, checks the row and, if it meets the criteria, converts it to an X lock.
  • 20. Intent locks  An intent lock is used on a "higher" level object to indicate that a lock (one of the types of locks described) is being taken within that object.  We can have intent shared (IS) locks, intent exclusive locks (IX), and even intent update locks (IU)  For example, a transaction that holds an X lock on a row in the Customers table will also hold IX locks on both the page containing that row, and the Customers table  These Intent locks will prevent another transaction from locking the entire Customers table (acquiring an X lock on the table).  Whenever a transaction acquires a lock at a lower level of granularity, it also acquires higher-level intent locks for the same object.
  • 21. Lock duration  The length of time that SQL Server holds a lock depends primarily on the mode of the lock and the transaction isolation level that is in effect. READ COMMITTED  SQL Server releases S locks as soon as it has read and processed the locked data.  It holds an X lock until the end of the transaction, whether the transaction is committed or rolled back.  It holds a U lock until the end of the transaction, unless it promoted the U lock to an X lock, in which case the X lock, as with all X locks, remains for the duration of the transaction. REPEATABLE READ or SERIALIZABLE  S locks have the same duration as X locks.  That is, SQL Server does not release them until the trans-action is over.  In addition to changing the transaction isolation level, we can control the lock duration by using lock hints.
  • 22. Lock ownership  Lock duration is directly affected by lock ownership  Ownership == scope of the lock Four types of lock scopes  Transactions – Durations depend on isolation level and lock mode (shared locks and update/exclusive locks)  SHARED_TRANSACTION_WORKSPACE – Every connection in any database (other than master or tempdb) acquires a lock with this owner by. By observing these locks, SQL Server can tell when a database is in use. SHARED_TRANSACTION_WORKSPACE locks are held as long as a connection is using a database.  EXCLUSIVE_TRANSACTION_WORKSPACE – SQL Server acquires a lock with this owner whenever it needs exclusive access to the database. This includes activities such as dropping the database, restoring the database, or changing certain database properties, such as the READ_ONLY status.  Cursors – requested explicitly when a cursor is declared. If a cursor is opened using a locking mode of SCROLL_LOCKS, a cursor lock is held on every row fetched until the next row is fetched or the cursor is closed. Even if the transaction commits before the next fetch, the cursor lock is not released
  • 23.
  • 24.
  • 25. Mahabubur Rahaman Senior Database Architect Orion Informatics Ltd