Validating row at client side better than secondary index with whole primary key?

前端 未结 2 582
我寻月下人不归
我寻月下人不归 2021-01-23 22:55

In cassandra, it\'s well known that secondary indexes should be used very sparingly.

If I have a table for example:

User(username, usertype, email, etc..         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-23 23:40

    The good option here would be to create a composite primary key consisting of username and usertype with username being partition key and usertype a cluster key. You will not even need an index and the query will work.

    CREATE TABLE users (
      username text,
      usertype text,
       ....
      PRIMARY KEY ((username), usertype)
    )
    

提交回复
热议问题