将 "is_deleted" 状态字段作为复合主键放在 cassandra table 上进行读取是一种好做法吗?
Is putting "is_deleted" state field as composite primary key on cassandra table for read is good practice?
我正在 spring 上设置新的反应式 cassandra 休息服务,然后有 "default" 字段,如 is_deleted
、is_active
、storeid
等,在所有表上。
因为假设 where 查询需要 is_deleted。
它被创建为复合PK之一,因此数据搜索会更快。
问题在于,主键非常胖,搜索查询变得很长,因为它需要提及所有默认键。
在cassandra上进行如此胖的复合PK是不是一个好习惯?
@PrimaryKeyColumn(name = BaseCassandraFields.STORE_ID, type = PrimaryKeyType.PARTITIONED)
protected String storeId;
@PrimaryKeyColumn(name = BaseCassandraFields.IS_DELETED, type =
PrimaryKeyType.PARTITIONED)
protected Boolean isDeleted = false;
Example of table
Also here is the DDL
它不会在内部影响 Cassandra,但如果您不需要所有这些密钥,那么您就是在不必要地对开发部分施加压力。我个人觉得在 PK 中使用布尔值很奇怪,但您的用例可能会证明这一点。
您可能会争辩说,由于列数较多,Cassandra 在计算密钥的哈希值时可能会有一些额外的开销,但我怀疑这是否重要,因为哈希函数通常具有高性能。
我正在 spring 上设置新的反应式 cassandra 休息服务,然后有 "default" 字段,如 is_deleted
、is_active
、storeid
等,在所有表上。
因为假设 where 查询需要 is_deleted。 它被创建为复合PK之一,因此数据搜索会更快。
问题在于,主键非常胖,搜索查询变得很长,因为它需要提及所有默认键。
在cassandra上进行如此胖的复合PK是不是一个好习惯?
@PrimaryKeyColumn(name = BaseCassandraFields.STORE_ID, type = PrimaryKeyType.PARTITIONED)
protected String storeId;
@PrimaryKeyColumn(name = BaseCassandraFields.IS_DELETED, type =
PrimaryKeyType.PARTITIONED)
protected Boolean isDeleted = false;
Example of table
Also here is the DDL
它不会在内部影响 Cassandra,但如果您不需要所有这些密钥,那么您就是在不必要地对开发部分施加压力。我个人觉得在 PK 中使用布尔值很奇怪,但您的用例可能会证明这一点。
您可能会争辩说,由于列数较多,Cassandra 在计算密钥的哈希值时可能会有一些额外的开销,但我怀疑这是否重要,因为哈希函数通常具有高性能。