Avoiding and/or Minimizing Deadlocks
In relational database systems (RDBMS), a deadlock is a situation where two concurrent transactions cannot make progress because each one is waiting for the other to release the lock. In Part 1 of this series, we we established what Object Locking is in Relational Databases, the different types of locks, and deadlocking. Then, in Part 2, we compared the pros and cons of Pessimistic and Optimistic locking. In this installment, we'll be exploring a few causes of deadlocks, as well as strategies for avoiding, or at least, minimizing them.
Pessimistic versus Optimistic Locking
Relational database systems (RDBMS) employ various locking strategies to enforce transaction ACID properties when modifying (e.g., UPDATING or DELETING) table records. On occasion, deadlock may occur when two concurrent transactions cannot make progress because each one is waiting for the other to release the lock. In Part 1 of this series, we we established what Object Locking is in Relational Databases, the different types of locks, and deadlocking. In today's follow-up, we'll be comparing the pros and cons of Pessimistic and Optimistic locking.
Part 1: Overview, Lock Granularity, and Deadlocks
Recently, we've had a few blogs about database transactions and they enforce the the four ACID (Atomicity Consistency Isolation Durability) properties. In today's blog, we'll be taking a look at another mechanism employed by relational databases (RDBMS) to enforce ACID properties, namely, Object Locking. Specifically, we'll learn what it is, what role(s) it plays in RDBMS transactions, and some of the side effects locking may cause. While Database Object Locking can be a fairly technical and complicated subject, we're going to break it down into layman's terms here and keep things as simple as possible.
Back in August of 2020, The Many Flavors of the SQL Count() Function provided an overview of COUNT's many input parameter variations. Another way to use the COUNT() function is to combine it with the GROUP BY clause. Using the COUNT() function in conjunction with GROUP BY is useful for breaking down counts according to various groupings. In today's blog, we'll learn how to group counts by different criteria by querying the Sakila Sample Database using Navicat Premium as our database client.
Part 4: Miscellaneous Functions
This last category of important SQL Server functions includes those that deal with nulls, conversion, and control flow. Far from leftovers, these functions are among some of the most useful you'll ever come across!
COALESCE
Anytime you select a column whose value is not mandatory, you're bound to encounter null values. That only makes sense, because null values represent absent or missing information. Trouble is, nulls can reek havoc when included in calculations as well as other operations that one might perform on column data.
- 2024 (1)
- 2023 (1)
- 2022 (1)
- 2021 (1)
- 2020 (1)
- 2019 (1)
- 2018 (1)
- 2017 (1)