Never miss a story

Get subscribed to our newsletter


×
SQL came up as a declarative language for database management. (Representational Image). Pinterest

At the baseline, every database is a very simple soul. A good database is meant to ingest your data, process it, and return it to the users when needed in whatever form they want it. To be practical for the needs in hand, any given database must allow as many queries as possible to be simultaneously processed. SQL came up as a declarative language for database management.

This does not mean that an SQL statement dictates the database as to how to perform a query. Still, it just raises the parameters with which a database can operate within itself while a statement is executed. In other terms, a programmer who interacts with the given database is ceding control over the specifics to a database. The application logic gets separated from the data storage with this approach. As a result, the database itself becomes capable of managing multiple simultaneous requests. Most specifically, a database has to handle situations where more than one reads and writes transactions on the same piece of data.


Follow NewsGram on LinkedIn to know what’s happening around the world.

Read/write lock

The conventional coders may raise a question as to why don’t we try to read/write locks to handle this? It is reasonable to raise this question as to the most adopted solution for databases for years. However, there is a problem with this approach. The readers may tend to block the writers and vice versa. These come as the semantics of a standard read/write lock. In the case of a transactional database, these semantics may have a bigger adverse impact on the performance.


A set of write data on a short-running transaction may get blocked until the former transaction completes.

You may consider a system with two different kinds of transactions. One may be a long-running read transaction that builds up a report or likes doing some analytics. Consider there is only one among these that may be running at one time. Another transaction may be a short-running user action with more than one write or read at a time. An order request or similar transaction can be considered as an example. In a typical web application environment, there can be thousands of such transactions.

Here, the primary problem with a standard read/write lock is that there can be an overlap between the set of read data for a long-running transaction. A set of write data on a short-running transaction may get blocked until the former transaction completes. In the tangled internet world of interweb now, even a long-running transaction that runs for a few seconds is unacceptable to the end-users. A study shows that the bounce rate is high for the web pages, which has a response delay of more than 3 seconds. If you are looking for better database solutions to ensure uptime and performance of your web applications, check out what RemoteDBA got to offer you.

The role of Multi-Version Concurrency Control (MVCC)

Considering the above challenge, there is some ‘wow’ factor about what MVCC or Multi-Version Concurrency Control solve. The name itself suggests how it solves the problem. Rather than maintaining predetermined storage space for any given record and applying read/write as lock as done conventionally, an MVCC DB will let a given record keep multiple versions simultaneously.

This means the updates are now installing another fresh row version. With this, the writers are contesting over their rights toa dd a new version on top of the given row, and the readers can read from any visible version out there. This means that long-running transactions will not lock again even when the short transaction queries are processed. Only if two or more transactions are vying for update rights on a row version, there is a possibility of mutual interference. We can see that MVCC is ideally used to implement the snapshots of a database.

As an effect of the same, while a transaction initiates, it gets freeze with a collection of unique records as a visible set. Updates of these versions are logically sequenced after the transactions are read. All that DBAs need to do is support the MVCC semantics as a record storage system that stores various versions of the same record. It also acts as a mechanism that allows users to translate the record version number to transaction IDs to make the visibility calculations.


In the case of MVCC, it means that while a transaction hits a specific record updated by another concurrent transaction, the action depends on its isolation level. (Representational Image). Unsplash

MVCC and SQL

MVCC system can be used to implement the SQL semantics concurrently. SQL offers different isolation levels, which acts as a knob allowing the programmersto dial in a level of consistency needed. In the case of MVCC, it means that while a transaction hits a specific record updated by another concurrent transaction, the action depends on its isolation level. At the basic level of consistency, one may allow these transactions to read any update before the transaction update is committed, known as dirty read.

However, the next consistency level will prevent any dirty reads and just read the calculated version from the given transaction’s visibility. This is called ‘consistent reading.’ An update which hits a record version that undergoes an uncommitted update may have two options as:

  1. It can merely freak out, and straightaway fail, or,
  2. It can wait for the updated transaction to complete and then decide based on the committed state.

The low isolation levels fail faster as logically; they see the transactional updates as they run. The high consistency levels may need to block or retry based on the user needs until the ultimate record state is known.

For example, you can consider a table with 3 live rows. You may assume that each of these has some specific ID values. Provided this, we may examine the below use case.

Also Read: Asthma Patients Not At Risk From Covid-19

The first transaction starts before transaction 2 and begins to read each entry in the tale. Simultaneously, transaction 2 also starts up and looks for updatable records. Transaction #2 may outrace the first transaction to the record 100 and slips in early to updates it. A second transaction is still running; the update is pending. In a lock-based system, transaction 1 may have to get locked or validate that no record is changed while it was reading. On the other hand, in the MVCC model, while the first transaction finally gets around to read the record 100, it reads the most recent version. As a result, no reader is blocking a writer, and no one has to roll back or block.

This way, MVCC concurrency control can ensure multi-version concurrency in SQL distributed databases. It is proved to be the right approach for the DBAs to ensure database concurrency by providing better performance.


Popular

IANS

The aim of the book is to teach children that families can exist in different forms, and show them how to accept the diversity in family backgrounds.

By Siddhi Jain

Delhi-based author Pritisha Borthakur is set to release her new book, 'Puhor and Niyor's Mural of Family Stories'. The 1,404-word children's book was put together to address a new kind of societal debacle in the family system. The author says the aim is to teach children that families can exist in different forms, and show them how to accept the diversity in family backgrounds.

The author who named the book after her twin sons -- Puhor and Niyor -- is a parent who has seen and heard the tales of ridicule and discrimination suffered by many in India and beyond. She says the book is an artistic illustration for kids that details how different families can live and coexist. Whether it's children with two dads or two moms, children with a single dad or single mom, and even multiracial family units, Borthakur's book teaches love, understanding, and compassion towards unconventional families.

Beyond race, gender, color, and ethnicity which have formed the bases for discrimination since the beginning of time, this book aims to bring to light a largely ignored issue. For so long, single parents have been treated like a taboo without any attempt to understand their situations; no one really cares how or why one's marriage ended but just wants to treat single parents as villains simply for choosing happiness and loving their children.

Homosexual parents, a relatively new family system, is another form that has suffered hate and discrimination for many years. Pritisha emphasizes the need to understand that diversity in people and family is what makes the world beautiful and colourful. 'Puhor and Niyor's Mural of Family Stories' is a firm but compassionate statement against all forms of discrimination on the bases of sexual identity, gender, race, and even differences in background

four children standing on dirt during daytime 'Puhor and Niyor's Mural of Family Stories' is a firm but compassionate statement against all forms of discrimination on the bases of sexual identity, gender, race and even differences in background. | Photo by Ben Wicks on Unsplash


Keep Reading Show less
Photo by Lina Trochez on Unsplash

Clean and maintained hands boost confidence in daily life activities.

If you feel that clean and well-groomed hands are just an essential prerequisite for women, you might like to think twice. Men should equally pay attention to their hands because our hand houses 1,500 bacteria living on each square centimeter of its skin. You can easily assume what havoc it can create in our body because in India we have the culture of eating with our hands and spaces beneath nails can become breeding heaven for germs. Moreover, clean and maintained hands boost confidence in their daily life activities. Therefore, it's important to keep your hands clean irrespective of your gender by washing or sanitizing at regular intervals. And, to keep them groomed, you don't have to visit a salon.

Rajesh U Pandya, Managing Director, KAI India, gives easy and completely doable tips to follow at home:

* Refrain from harsh soaps: You should be mindful of the soap you are using to wash your hands. Your soap can have a moisturizing element in it like aloe vera or shea butter. Ensure that you're washing your hands with normal water as hot water can make your hand's skin dry and scaly.

Soap bars organic You should be mindful of the soap you are using to wash your hands. | Photo by Aurélia Dubois on Unsplash

Keep Reading Show less
Photo by Dmitry Demidko on Unsplash

Bitcoin has become an essential crypto asset in modern portfolios and investment funds.

Bitcoin has become an essential crypto asset in modern portfolios and investment funds. The confidence generated in this cryptocurrency will depend a lot on the diversification that companies make in their balance sheets in Bitcoin and the increase of institutional investors that allocate a percentage of their funds in this crypto. American fund manager Cathie Wood makes some interesting predictions, both in the rise that the Bitcoin price will experience in the next 5 years, suggesting these institutional investors allocate 5% of their funds; this will help leverage the Bitcoin market.

Bitcoin will grow by a tenfold

Keep reading... Show less