You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Check Peck <co...@gmail.com> on 2014/09/24 00:23:23 UTC
How to get data which has changed within x minutes using CQL?
I have a table structure like below -
CREATE TABLE client_data (
client_id int,
consumer_id text,
last_modified_date timestamp,
PRIMARY KEY (client_id, last_modified_date, consumer_id)
)
I have a query pattern like this - Give me everything for what has changed
withing last 15 minutes or 5 minutes? Is this possible to in CQL with the
above tables?
Re: How to get data which has changed within x minutes using CQL?
Posted by Tobias Widén <To...@trioptima.com>.
You could have two tables with the data inserted with TTL=5 minutes in one and TTL=15 minutes in the other. Just select everything from the appropriate table.
Having separate tables for different TTLs is also a good practice for keeping your SSTables in good condition.
From: DuyHai Doan <do...@gmail.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Date: Wednesday 24 September 2014 00:58
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: Re: How to get data which has changed within x minutes using CQL?
No, you need to compute yourself now - 15mins. CQL3 does not offer built-in functions to deal with dates right now
Le 24 sept. 2014 00:47, "Check Peck" <co...@gmail.com>> a écrit :
On Tue, Sep 23, 2014 at 3:41 PM, DuyHai Doan <do...@gmail.com>> wrote:
now - 15 mins
Can I run like this in CQL using cqlsh?
SELECT * FROM client_data WHERE client_id = 1 and last_modified_date >= now - 15 mins
When I ran the above query I got an error on my cql client -
Bad Request: line 1:81 no viable alternative at input '-'
Re: How to get data which has changed within x minutes using CQL?
Posted by DuyHai Doan <do...@gmail.com>.
No, you need to compute yourself now - 15mins. CQL3 does not offer built-in
functions to deal with dates right now
Le 24 sept. 2014 00:47, "Check Peck" <co...@gmail.com> a écrit :
>
> On Tue, Sep 23, 2014 at 3:41 PM, DuyHai Doan <do...@gmail.com> wrote:
>
>> now - 15 mins
>
>
>
> Can I run like this in CQL using cqlsh?
>
> SELECT * FROM client_data WHERE client_id = 1 and last_modified_date >=
> now - 15 mins
>
> When I ran the above query I got an error on my cql client -
>
> Bad Request: line 1:81 no viable alternative at input '-'
>
>
Re: How to get data which has changed within x minutes using CQL?
Posted by Check Peck <co...@gmail.com>.
On Tue, Sep 23, 2014 at 3:41 PM, DuyHai Doan <do...@gmail.com> wrote:
> now - 15 mins
Can I run like this in CQL using cqlsh?
SELECT * FROM client_data WHERE client_id = 1 and last_modified_date >= now
- 15 mins
When I ran the above query I got an error on my cql client -
Bad Request: line 1:81 no viable alternative at input '-'
Re: How to get data which has changed within x minutes using CQL?
Posted by DuyHai Doan <do...@gmail.com>.
let previous15Min = now - 15 mins
SELECT * FROM client_data WHERE client_id = 1 and last_modified_date >=
previous15Min
Same thing for last 5 mins
On Wed, Sep 24, 2014 at 12:32 AM, Check Peck <co...@gmail.com>
wrote:
> Yes I can provide client_id in my where clause. So now my query pattern
> will be -
>
> Give me everything for what has changed within last 15 minutes or 5
> minutes whose client_id is equal to 1?
>
> How does my query will look like then?
>
>
> On Tue, Sep 23, 2014 at 3:26 PM, DuyHai Doan <do...@gmail.com> wrote:
>
>> It is possible to request a "range" of data according to the
>> last_modified_date but you still need to provide the client_id , the
>> partition key, in any case
>>
>>
>> On Wed, Sep 24, 2014 at 12:23 AM, Check Peck <co...@gmail.com>
>> wrote:
>>
>>> I have a table structure like below -
>>>
>>> CREATE TABLE client_data (
>>> client_id int,
>>> consumer_id text,
>>> last_modified_date timestamp,
>>> PRIMARY KEY (client_id, last_modified_date, consumer_id)
>>> )
>>>
>>> I have a query pattern like this - Give me everything for what has
>>> changed withing last 15 minutes or 5 minutes? Is this possible to in CQL
>>> with the above tables?
>>>
>>
>>
>
Re: How to get data which has changed within x minutes using CQL?
Posted by Check Peck <co...@gmail.com>.
Yes I can provide client_id in my where clause. So now my query pattern
will be -
Give me everything for what has changed within last 15 minutes or 5 minutes
whose client_id is equal to 1?
How does my query will look like then?
On Tue, Sep 23, 2014 at 3:26 PM, DuyHai Doan <do...@gmail.com> wrote:
> It is possible to request a "range" of data according to the
> last_modified_date but you still need to provide the client_id , the
> partition key, in any case
>
>
> On Wed, Sep 24, 2014 at 12:23 AM, Check Peck <co...@gmail.com>
> wrote:
>
>> I have a table structure like below -
>>
>> CREATE TABLE client_data (
>> client_id int,
>> consumer_id text,
>> last_modified_date timestamp,
>> PRIMARY KEY (client_id, last_modified_date, consumer_id)
>> )
>>
>> I have a query pattern like this - Give me everything for what has
>> changed withing last 15 minutes or 5 minutes? Is this possible to in CQL
>> with the above tables?
>>
>
>
Re: How to get data which has changed within x minutes using CQL?
Posted by DuyHai Doan <do...@gmail.com>.
It is possible to request a "range" of data according to the
last_modified_date but you still need to provide the client_id , the
partition key, in any case
On Wed, Sep 24, 2014 at 12:23 AM, Check Peck <co...@gmail.com>
wrote:
> I have a table structure like below -
>
> CREATE TABLE client_data (
> client_id int,
> consumer_id text,
> last_modified_date timestamp,
> PRIMARY KEY (client_id, last_modified_date, consumer_id)
> )
>
> I have a query pattern like this - Give me everything for what has changed
> withing last 15 minutes or 5 minutes? Is this possible to in CQL with the
> above tables?
>