You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Rahul Gupta <rg...@dekaresearch.com> on 2014/10/06 20:27:26 UTC

RE: Cassandra Data Model design

You need rethink your data model for client_data table.
Unlike RDBMS, Cassandra heavily relies on Primary Key for filtering data.

In fact using any column other than primary key is not recommended when you are using Cassandra.
This means that how you design your Primary Key is critical.

There are two options in this case:


1.       Use both client_name and is_valid as Row Key

2.       Use client_name as Row Key and is_valid as partitioning key or in other words, make a composite key using client_name and is_valid

Cassandra Data Model Rule: You need to know your query patterns before you create a table.

Rahul Gupta

From: Check Peck [mailto:comptechgeeky@gmail.com]
Sent: Wednesday, September 17, 2014 4:01 PM
To: user
Subject: Cassandra Data Model design

I have recently started working with Cassandra. We have cassandra cluster which is using DSE 4.0 version and has VNODES enabled. We have a tables like this -

Below is my first table -

    CREATE TABLE customers (
      customer_id int PRIMARY KEY,
      last_modified_date timeuuid,
      customer_value text
    )

Read query pattern is like this on above table as of now since we need to get everything from above table and load it into our application memory every x minutes.

    select customer_id, customer_value from datakeyspace.customers;

We have second table like this -

    CREATE TABLE client_data (
      client_name text PRIMARY KEY,
      client_id text,
      creation_date timestamp,
      is_valid int,
      last_modified_date timestamp
    )

Right now in the above table, we have 500 records and all those records has "is_valid" column value set as 1. And the read query pattern is like this on above table as of now since we need to get everything from above table and load it into our application memory every x minutes so the below query will return me all 500 records since everything has is_valid set to 1.

    select client_name, client_id from  datakeyspace.client_data where is_valid=1;

Since our cluster is VNODES enabled so my above query pattern is not efficient at all and it is taking lot of time to get the data from Cassandra. We are reading from these table with consistency level QUORUM.

Is there any possibility of improving our data model?

Any suggestions will be greatly appreciated.


Click here<https://www.mailcontrol.com/sr/kSV!iHJdoezGX2PQPOmvUgEBY15Clgt1yZCwVg0S2deEmu+55HoGlTWtq8oOngZ2yx9zvjq!hshkxH4nYzTQYQ==> to report this email as spam.

________________________________
This e-mail and the information, including any attachments it contains, are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.