16

我读过一些文章说MySQL等RDBMS不擅长扩展,但MongoDB等NoSQL可以很好地分片。 我想知道 RDBMS 提供的哪个特性使自己不能很好地分片。

4

3 回答 3

55

Most RDBMS systems guarantee the so-called ACID properties. Most of these properties boil down to consistency; every modification on your data will transfer your database from one consistent state to another consistent state.

For example, if you update multiple records in a single transaction, the database will ensure that the records involved will not be modified by other queries, as long as the transaction hasn't completed. So during the transaction, multiple tables may be locked for modification. If those tables are spread across multiple shards/servers, it'll take more time to acquire the appropriate locks, update the data and release the locks.

The CAP theorem states that a distributed (i.e. scalable) system cannot guarantee all of the following properties at the same time:

  • Consistency
  • Availability
  • Partition tolerance

RDBMS systems guarantee consistency. Sharding makes the system tolerant to partitioning. From the theorem follows that the system can therefor not guarantee availability. That's why a standard RDBMS cannot scale very well: it won't be able to guarantee availability. And what good is a database if you can't access it?

NoSQL databases drop consistency in favor of availability. That's why they are better at scalability.

I'm not saying RDBMS systems cannot scale at all, it's just harder. This article outlines some of the possible sharding schemes, and the problems you may encounter. Most approaches sacrifice consistency, which is one of the most important features of RDBMS systems, and which prevents it from scaling.

于 2010-08-06T12:31:48.717 回答
2

为什么 NoSQL 帅哥和帅哥不喜欢加入:http ://www.dbms2.com/2010/05/01/ryw-read-your-writes-consistency/

于 2010-08-06T19:16:21.033 回答
1

涉及多个分片的查询很复杂(不同分片中表之间的 FE JOIN)

于 2010-08-06T11:20:08.157 回答