Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5F42CE728 for ; Fri, 1 Mar 2013 16:16:51 +0000 (UTC) Received: (qmail 64093 invoked by uid 500); 1 Mar 2013 16:16:48 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 64059 invoked by uid 500); 1 Mar 2013 16:16:48 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 64051 invoked by uid 99); 1 Mar 2013 16:16:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 16:16:48 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of aventurella@gmail.com designates 74.125.82.169 as permitted sender) Received: from [74.125.82.169] (HELO mail-we0-f169.google.com) (74.125.82.169) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 16:16:40 +0000 Received: by mail-we0-f169.google.com with SMTP id t11so2710433wey.14 for ; Fri, 01 Mar 2013 08:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=EXra5XAq2cipVFrYZ1sFZFLgwbkBOn4J65hFk6g/NZw=; b=gOc+rOlsg3rTk4heV2Lb2E28Sa9Xcg3MvuomeAWUus0c5dNgsqHhmsIi1+NG+JujPb 3wM1INwIMA2pRmgbAQe1/nar8vxRz+SSmtID0yWb5Yx6VcHSsOs/jm4xW7ReqhbL5SYx C9Zqbfhx1EXVo9aYNjn8hfVqVfPKj3VgwC/7JUbOKpgSnGmgc+2iWT7fhx+HLbaZpmu9 EAlzhp+mgHcDyK1f3uhhx4C0Ub50+6o243nmBqBZt31AA/bc82/oM7Y8vdwGjVXgLIse E9a/bk0+LYmR3llqOj9RAwHy9yrka/isKUWBnSq3ZUnDBeJxXmFcwAIIyORv4QnKypWV BpUQ== MIME-Version: 1.0 X-Received: by 10.194.119.200 with SMTP id kw8mr18537090wjb.31.1362154579294; Fri, 01 Mar 2013 08:16:19 -0800 (PST) Received: by 10.194.26.134 with HTTP; Fri, 1 Mar 2013 08:16:19 -0800 (PST) Date: Fri, 1 Mar 2013 08:16:19 -0800 Message-ID: Subject: CQL3 to ORDER BY Verification From: Adam Venturella To: "user@cassandra.apache.org" Content-Type: multipart/alternative; boundary=089e01177913d4028b04d6df538f X-Virus-Checked: Checked by ClamAV on apache.org --089e01177913d4028b04d6df538f Content-Type: text/plain; charset=ISO-8859-1 My ColumnFamily is defined as follows: CREATE TABLE UserProfileHistory( username text, timestamp bigint, -- millis since epoch data text, -- JSON PRIMARY KEY (username, timestamp) ) WITH CLUSTERING ORDER BY (timestamp DESC); Each insert on the username adds to the wide row. The most recent profile history being able to be retrieved by SELECT * FROM UserProfileHistory WHERE username=:username LIMIT 1; For some reporting needs I need to fetch the entire history, and I need to do it in ASC order instead of DESC. One option is to do the sorting in code, collect N results, sort on the timestamps accordingly. Given the row is of N length, that could start to put an undo memory burden in my application layer, and I would like to avoid that if possible opting instead for Cassandra to perform the work. So I am leaning towards this option: 2) min timestamp seek + ORDER BY To start the process my initial timestamp would be 01-01-1970T12:00:00+0000 (assume that is in milliseconds, aka 0) I would then issue my query: SELECT * FROM UserProfileHistory WHERE username=:username AND timestamp > :milliseconds ORDER BY timestamp ASC LIMIT 100 Once I have those initial results I would just pick my last timestamp from the result set and + 1 on it and run the query again until I received 0 results. The CQL works and returns my results as I expect. This will probably only be run once every 24 hours, maybe every 12 hours; point being, not often. Am I setting myself up for a disaster down the line? --089e01177913d4028b04d6df538f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
My ColumnFamily is defined as follows:

=
CREATE TABLE UserProfileHistory(
=A0 =A0 user= name text,
=A0 =A0 timestamp bigint, -- millis since epoch
<= div>=A0 =A0 data text, -- JSON
=A0 =A0 PRIMARY KEY (username, timestamp)
) WITH CLUSTERING = ORDER BY (timestamp DESC);


Each insert on the username adds to the wide row. The most recent profi= le history being able to be retrieved by=A0

SELECT * FROM UserProfileHistory WHERE user= name=3D:username LIMIT 1;

For some rep= orting needs I need to fetch the entire history, and I need to do it in ASC= order instead of DESC.

One option is to do the sorting in code, co= llect N results, sort on the timestamps accordingly. Given the row is of N = length, that could start to put an undo memory burden in my application lay= er, and I would like to avoid that if possible opting instead for Cassandra= to perform the work.


So I am leaning toward= s this option:

2) min timestamp seek += ORDER BY

To start the process my init= ial timestamp would be 01-01-1970T12:00:00+0000 (assume that is in millisec= onds, aka 0) I would then issue my query:

SELECT * FROM UserProfileHistory WHERE user= name=3D:username AND timestamp > :milliseconds ORDER BY timestamp ASC LI= MIT 100

Once I have those initial = results I would just pick my last timestamp from the result set and + 1 on = it =A0and run the query again until I received 0 results.


The CQL works and retu= rns my results as I expect. This will probably only be run once every 24 ho= urs, maybe every 12 hours; point being, not often.

Am I setting myself up for a disaster down the line?=A0
--089e01177913d4028b04d6df538f--