我试图了解Cassandra数据模型的基本原理.我正在使用CQL.据我所知,必须先定义架构,然后才能插入新列.如果有人需要添加任何列,可以使用ALTER TABLE并将INSERT值插入该新列.
但是在cassandra权威指南中写道,Cassandra的架构较少.
In Cassandra, you don’t define the columns up front; you just define the column families you want in the keyspace, and then you can start writing data without defining the columns anywhere. That’s because in Cassandra, all of a column’s names are supplied by the client.
我感到困惑,没有找到任何预期的答案.有人可以向我解释或告诉我,如果我错过了什么吗?
提前致谢.
我试图理解Cassandra中的Leveled Compaction Strategy如何保证所有读取的90%将从单个sstable中得到满足.
来自DataStax Doc:
新的sstables被添加到第一级L0,并立即用L1中的sstables压缩.当L1填满时,额外的sstables被提升为L2.在L1中生成的后续sstables将与它们重叠的L2中的sstables一起压缩.
CREATE TABLE users ( userId uuid, firstname varchar, mobileNo varchar, PRIMARY KEY (userId) );
CREATE TABLE users_by_firstname ( userId uuid, firstname varchar, mobileNo varchar, PRIMARY KEY (firstname,userId) );
我在这些表中有100行.我想每次随机选择10行.
在MySQL中
通过RAND()限制10从用户订单中选择*;
在卡桑德拉
select*from users limit 10;
select*from users_by_firstname limit 10;
但是从第一个表中我将得到静态的10行,它们按生成的分区键(userId)的哈希值排序.
从第二个我将获得由userId排序的静态10行.但如果数据没有改变,它将不是随机的.
有没有办法在Cassandra中每次获取随机行.
谢谢
Chaity