You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Moses Dinakaran <mo...@gmail.com> on 2010/05/12 14:34:34 UTC

Is it possible to delete records based upon where condition

Hi All,

In Cassandra it possible to remove records based upon where condition.

We are planning to move the session and cache table from MySql to Cassandra
and where doing the fesability study. Everything seems to be Ok other than
garbage collection of session table.

Was not able to  remove super columns from the Key based upon certain
conditions in the column value.

Follows the schema for Session tables


FESession  = {
    sessions : {
    1001 : {
    ses_name       : "user",
    ses_userid      :  258,
    ses_tstamp    : “1273504587”
    },
    1002 : {
    ses_name    : "user",
    ses_userid    :  259,
    ses_tstamp    : “1273504597”
    },
    },
}

I wanted to remove the records based upon the value of the column ses_tstamp
ie (delete from sessions where ses_tstamp between XXX & YYY OR delete from
session where ses_tstamp < XXX )

Is it possible to achieve this in Cassandra If so  please let me know how.

To my knowledge I dont see any kind of where condition in Casandra,
If that is the case also please let me know the other ways like
restructuring the Schema or whatever...

Regards
Moses

Re: Is it possible to delete records based upon where condition

Posted by Moses Dinakaran <mo...@gmail.com>.
Hi
Thanks for the answers,
we are planning to run a cron job that fetches the record and deletes
one by one.
A post which gives more details on this
http://www.mail-archive.com/cassandra-user@incubator.apache.org/msg02610.html

Regards,
Moses.

On 5/13/10, Joel Pitt <jo...@gmail.com> wrote:
> On Thu, May 13, 2010 at 12:34 AM, Moses Dinakaran
> <mo...@gmail.com> wrote:
>> I wanted to remove the records based upon the value of the column
>> ses_tstamp
>> ie (delete from sessions where ses_tstamp between XXX & YYY OR delete from
>> session where ses_tstamp < XXX )
>>
>> Is it possible to achieve this in Cassandra If so  please let me know how.
>
> From my limited understanding of Cassandra (haven't actually deployed
> it and have mostly just been learning from reading for now) the way
> you'd want to do this is by either rearranging your schema (or
> manually creating an index) so that the timestamps are used as the
> column names within a CF that is sorted by the timestamp.
>
> Joel Pitt, PhD | http://ferrouswheel.me
> OpenCog Developer | http://opencog.org
> Board member, Humanity+ | http://humanityplus.org
>

Re: Is it possible to delete records based upon where condition

Posted by Joel Pitt <jo...@gmail.com>.
On Thu, May 13, 2010 at 12:34 AM, Moses Dinakaran
<mo...@gmail.com> wrote:
> I wanted to remove the records based upon the value of the column ses_tstamp
> ie (delete from sessions where ses_tstamp between XXX & YYY OR delete from
> session where ses_tstamp < XXX )
>
> Is it possible to achieve this in Cassandra If so  please let me know how.

>From my limited understanding of Cassandra (haven't actually deployed
it and have mostly just been learning from reading for now) the way
you'd want to do this is by either rearranging your schema (or
manually creating an index) so that the timestamps are used as the
column names within a CF that is sorted by the timestamp.

Joel Pitt, PhD | http://ferrouswheel.me
OpenCog Developer | http://opencog.org
Board member, Humanity+ | http://humanityplus.org

Re: Is it possible to delete records based upon where condition

Posted by Benjamin Black <b...@b3k.us>.
The functionality of a WHERE clause usually means maintaining an
inverted index, usually another CF, on the information of interest
(ses_tstamp in your example).  You then retrieve index rows from that
CF to find the data rows.


b

On Wed, May 12, 2010 at 5:34 AM, Moses Dinakaran
<mo...@gmail.com> wrote:
> Hi All,
>
> In Cassandra it possible to remove records based upon where condition.
>
> We are planning to move the session and cache table from MySql to Cassandra
> and where doing the fesability study. Everything seems to be Ok other than
> garbage collection of session table.
>
> Was not able to  remove super columns from the Key based upon certain
> conditions in the column value.
>
> Follows the schema for Session tables
>
>
> FESession  = {
>     sessions : {
>     1001 : {
>     ses_name       : "user",
>     ses_userid      :  258,
>     ses_tstamp    : “1273504587”
>     },
>     1002 : {
>     ses_name    : "user",
>     ses_userid    :  259,
>     ses_tstamp    : “1273504597”
>     },
>     },
> }
>
> I wanted to remove the records based upon the value of the column ses_tstamp
> ie (delete from sessions where ses_tstamp between XXX & YYY OR delete from
> session where ses_tstamp < XXX )
>
> Is it possible to achieve this in Cassandra If so  please let me know how.
>
> To my knowledge I dont see any kind of where condition in Casandra,
> If that is the case also please let me know the other ways like
> restructuring the Schema or whatever...
>
> Regards
> Moses
>
>
>
>
>
>
>