如何在Scyllab和cassandra中使用静态柱?
我是锡拉布和卡桑德拉的新手,在查询表中的数据时遇到了一些问题,以下是我创建的模式:如何在Scyllab和cassandra中使用静态柱?,cassandra,scylla,Cassandra,Scylla,我是锡拉布和卡桑德拉的新手,在查询表中的数据时遇到了一些问题,以下是我创建的模式: CREATE TABLE usercontacts ( userID bigint, -- userID contactID bigint, -- Contact ID lynkApp userID contactDeviceToken text, -- Device Token
CREATE TABLE usercontacts (
userID bigint, -- userID
contactID bigint, -- Contact ID lynkApp userID
contactDeviceToken text, -- Device Token
modifyDate timestamp static ,
PRIMARY KEY (contactID,userID)
);
CREATE MATERIALIZED VIEW usercontacts_by_contactid
AS SELECT userID, contactID, contactDeviceToken,
FROM usercontacts
contactID IS NOT NULL AND userID IS NOT NULL AND modifyDate IS NOT NULL
-- Need to not null as these are the primary keys in main
-- table same structure as the main table
PRIMARY KEY(userID,contactID);
CREATE MATERIALIZED VIEW usercontacts_by_modifyDate
AS SELECT userID,contactID,contactDeviceToken,modifyDate
FROM usercontacts WHERE
contactID IS NOT NULL AND userID IS NOT NULL AND modifyDate IS NOT NULL
-- Need to not null as these are the primary keys in main
-- table same structure as the main table
PRIMARY KEY (modifyDate,contactID);
我想为联系人表创建物化视图,它是usercontacts\u by\u userid
和usercontacts\u by\u modifydate
当我将modifydate(timestamp)设置为静态时,我需要以下查询:
当前无法创建包含静态列(作为主键的一部分或仅作为常规列)的物化视图 包含静态行需要在静态列更改时读取整个基表(
usercontacts
),以便可以重新计算视图行。这对性能有很大的影响
将静态行作为视图的分区键意味着对于分区的所有行,视图中只有一个条目。然而,二级索引在这种情况下确实有效,您可以使用它
目前,这对“锡拉”和“卡桑德拉”都有效。目前无法创建包含静态列(作为主键的一部分或仅作为常规列)的物化视图 包含静态行需要在静态列更改时读取整个基表(
usercontacts
),以便可以重新计算视图行。这对性能有很大的影响
将静态行作为视图的分区键意味着对于分区的所有行,视图中只有一个条目。然而,二级索引在这种情况下确实有效,您可以使用它
目前,这对“锡拉”和“卡桑德拉”都是有效的
update usercontacts set modifydate="newdate" where contactid="contactid"
select * from usercontacts_by_modifydate where modifydate="modifydate"
delete from usercontacts where contactid="contactid"