Database Reference
In-Depth Information
Figure 3-8 . Rows fetched for tweet date greater than or equal to 31 st December 2013 with the filtering allowed option
With a very large amount of data being distributed within a large cluster, running
such queries may degrade the application's performance, if a partition key is not
present with EQ/IN clause. It is recommended that users analyze data first before run-
ning such queries, rather than perform a range of queries specific to a partition key.
Expiring Columns
We can also set the TTL (Time To Live) value per each column in a Cassandra table.
Upon exceding the defined TTL, the column would be logically deleted and marked as
obsolete. Though memory will only be freed up during compaction.
For example, with the banking system a OTP (One Time Password) is generated
per request, and would expire after a certain time. For such scenarios, we can temporar-
ily create a column with TTL value.
Prior to Cassandra 2.x, setting the TTL value was possible via insert and update op-
erations. Now with 2.x we can also set the default TTL value for per column family/
table. For storing TTL and expiration time, the column family would required an addi-
tional eight bytes.
Let's explore TTL with a simple exercise.
1.
First, let's create a keyspace demo and column family TTLSample
create keyspace demo with replication =
{'class':'SimpleStrategy','replication_factor':1};
use demo;
create table "TTLsample"(user_id text PRIMARY
KEY, OTP text, name text);
2.
Let's insert a record in TTLsample table with TTL value set to 16
seconds
 
Search WWH ::




Custom Search