问题描述
在中,我看到下面的语句
At blog I see below statement
我有两个相关的问题。
I have two related questions on it .
不确定是什么使Mongo拥有比仅具有粗略支持的cassandra更好的支持?
Not sure what makes Mongo to have better support than cassandra which just has cursory support ?
我对上述陈述的理解是,cassandra仅支持单列而不是复合列的二级索引
My understanding on above statement is that cassandra supports secondary indexes only on single column not on composite column
我的理解是Mongo以类似于RDBMS的方式实现了secondar索引,但是不确定cassandra是如何在高层实现的?
My understanding is Mongo implements the secondar index in similar fashion as RDBMS but not sure how cassandra implements it at high level ?
推荐答案
Mongo与Cassandra是,Mongo是主/从数据库,而Cassandra是无主系统。
The major difference between Mongo & Cassandra is that, Mongo is mater/slave DB Vs Cassandra is a masterless system.
所有的写操作都发生在Mongo中的单个PRIMARY节点上,该节点被复制到SECONDARIES。因此,整个数据在单个节点中可用,因此具有辅助索引&通过它进行查询变得更加简单(就像其他RDBMS一样)。因此,它支持针对辅助索引的所有类型的查询。当我们转向Mongo Sharded系统而不是简单的副本集时,情况变得越来越复杂。
Having said that, all writes happen to a single PRIMARY node in Mongo which gets replicated to SECONDARIES. So the entire data is available in a single node and hence having a secondary index & querying by it becomes simpler (just like any other RDBMS). Hence it supports all types of queries against a secondary index. It gets complicated as we move towards a Mongo Sharded system vs a simple replicaset.
对于Cassandra,数据将基于分区键分布到多个节点中。现在,建立二级索引仅与该特定节点上的数据有关,并且不知道其他节点中的数据。因此查询二级索引中的列会导致分散收集,因为匹配的数据可能位于任何节点中。由于不涉及任何分区键来限制节点数量,因此这种类型的查询将非常慢(取决于群集大小)。
In case of Cassandra, the data is distributed into multiple nodes based on the partition key. Now building a secondary index is only relative to data on that particular node and is unaware about the data in other nodes. So querying for a column in secondary index results in scatter gather, because the matching data could lie in any node. As no partitioning key is involved to restrict number of nodes, this type of query would be very slow (depending on the cluster size).
因此在Mongo中进行RANGE查询没什么大不了的,因为整个数据都在PRIMARY节点中可用。而对于Cassandra,二级索引的范围扫描将意味着扫描该给定节点中的每一行。因此,范围查询可能需要很长时间,因此不被支持。
So having a RANGE query in Mongo is no big deal, because the entire data is available in PRIMARY node. While Cassandra the range scan of secondary index would mean scanning every row in that given node. So a range query can take forever and hence not supported.
这篇关于关于二级索引,Cassandra vs MongoDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!