Skip to content
Advertisement

Why to use NoSQL DB when we could scale out SQL DB by sharing?

I recently read that the NoSQL DB scale out more easily than the traditional SQL DB.

But consider that I have a huge table in SQL DB then I could easily distribute rows among multiple servers based on some hash function. For e.g. – If I have 4 servers I could do (id%4) where id is the primary key of the table to determine on which table to store that particular row.

By doing this we could not only scale out the SQL DB but could also ensure that ACID properties are being followed.

Then why would one need to use NoSQL ?

Advertisement

Answer

NOSQL databases tend to relax the ACID properties of databases. For instance, instead of “immediate” consistency, they allow “eventual” consistency.

That is, if you update a row in a table, then for some period of time after the transaction is committed other queries might see the old value. Eventually, everyone will see the same value.

Because this is relaxed, NOSQL datbases have more flexibility for optimizations — and particularly not waiting for all nodes in a cluster to agree to something.

Relational databases have not stood still for the past few decades, so they often offer variations on locking and transactions that come close.

In my experience, this can make a difference in very high volume transaction environments. However for many purposes, the guarantees of transactional integrity on a SQL database are worth the overhead.

Note: NOSQL really refers to a class of “alternative” databases. The “NO” in NOSQL stands for “not only”. In reality, I think of these as all being a part of an ecosystem of functionality. NOSQL can also refer to document stores, key-value pair databases, graph databases, GIS databases — and sophisticated databases of any type often have significant overlapping functionality.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement