如何在scylladb和cassandra中使用静态列?

fah*_*had 1 cassandra scylla

我是scylladb和cassandra的新手,我在查询表中的数据方面遇到了一些问题,以下是我创建的模式:

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);
Run Code Online (Sandbox Code Playgroud)

我想创建联系人表物化视图是usercontacts_by_useridusercontacts_by_modifydate

如果我设置modifydate(timestamp)static,我需要以下查询:

update usercontacts set modifydate="newdate" where contactid="contactid"
select * from usercontacts_by_modifydate where modifydate="modifydate"
delete from usercontacts where contactid="contactid"
Run Code Online (Sandbox Code Playgroud)

Dua*_*nes 6

目前无法创建包含静态列的物化视图,既可以作为主键的一部分,也可以作为常规列.

包含静态行将需要在usercontacts更改静态列时读取整个基表(),以便可以重新计算视图行.这显着降低了性能.

将静态行作为视图的分区键意味着视图中只有一个条目用于分区的所有行.但是,在这种情况下,二级索引可以正常工作,您可以使用它.

这对Scylla和Cassandra目前都有效.