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 B1DF1105C3 for ; Thu, 5 Dec 2013 15:44:51 +0000 (UTC) Received: (qmail 17260 invoked by uid 500); 5 Dec 2013 15:44:43 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 17241 invoked by uid 500); 5 Dec 2013 15:44:41 -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 17161 invoked by uid 99); 5 Dec 2013 15:44:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Dec 2013 15:44:41 +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 (athena.apache.org: domain of chris.wirt@struq.com designates 74.125.83.48 as permitted sender) Received: from [74.125.83.48] (HELO mail-ee0-f48.google.com) (74.125.83.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Dec 2013 15:44:35 +0000 Received: by mail-ee0-f48.google.com with SMTP id e49so3369946eek.21 for ; Thu, 05 Dec 2013 07:44:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:thread-index:content-language; bh=YSNII/z7gzcq8pZrfP0JQmZOt5XUM61QWjW8edzppVQ=; b=FuI/GlHoPqISXa2N9Uodycm9fxXBiVu2jj0FPxS2ilOWf3WVtURTHkXtK+PFvaiotH BtwkGg1R2RRiDLWkZiaz9zNnerneViPdaeqisYiQBfVJ1rZuZsGTdjL2RNVInVHunRsT LLHT1L6hTClDW+d+fvlgUOMCkKjtXV2zXS7SficWKD9JfJJ6FAjlZVIpWuKMHYraAKE6 Pbb8suAnTgnjKgfXac+DgK6Yk+jchhRm36YCmx1n0eI6HNhAevrFrI7Che1FB9dydD8h l1OMe3sMqoj95je+JuGt8NE3atgdsF82OljUf674FK/E3MW/MBelwZya40C6kUhRpuBD CPqQ== X-Gm-Message-State: ALoCoQm5c6JAEW4xsNFDIAecGA7EjE4b0ilBkI5S0j1115fQUY+KdO2gNYgE/N4ckjWcINauJlEp X-Received: by 10.15.75.68 with SMTP id k44mr17237569eey.57.1386258253301; Thu, 05 Dec 2013 07:44:13 -0800 (PST) Received: from StevePereiraPC ([217.138.42.98]) by mx.google.com with ESMTPSA id l4sm71617215een.13.2013.12.05.07.44.12 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Dec 2013 07:44:12 -0800 (PST) From: "Christopher Wirt" To: Subject: Counters question - is there a better way to count Date: Thu, 5 Dec 2013 15:44:12 -0000 Message-ID: <018501cef1d0$d89702f0$89c508d0$@struq.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0186_01CEF1D0.D898D7B0" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac7x0FyA2tA0SmJZRyeyNFhUTyhfug== Content-Language: en-gb X-Virus-Checked: Checked by ClamAV on apache.org This is a multipart message in MIME format. ------=_NextPart_000_0186_01CEF1D0.D898D7B0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I want to build a really simple column family which counts the occurrence of a single event X. Once we reach Y occurrences of X the counter resets to 0 The obvious way to do this is with a counter CF. CREATE TABLE xcounter1 ( id uuid, someid int, count counter ) PRIMARY KEY (uid, someid) This is how I've always done it in the past, but I've been told to avoid counters for various reasons, performance, consistency etc.. I'm not too bothered about 100% absolute consistency, however read performance is certainly a big concern. So I was thinking to avoid using counters I could do something like this. CREATE TABLE xcounter2 ( id uuid, someid int, time timeuuid ) PRIMARY KEY (uid, someid, time) Then retrieve all events and count in memory. Delete all id, someid records once I hit Y. Or I could CREATE TABLE xcounter3 ( id uuid, someid int, time timeuuid, Ycount int ) PRIMARY KEY (uid, someid, time) Insert a 'Ycount' on each occurrence of the event. Only retrieve the last Y value inserted on reading Then delete all records once I hit the magic Y value. Anyone have any interesting thoughts or insight on what is likely to give me the best read performance? There will be 100's of someid to each id. Reads will be 5-10x the writes. Thanks, Chris ------=_NextPart_000_0186_01CEF1D0.D898D7B0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I want to = build a really simple column family which counts the occurrence of a = single event X.

 

Once we = reach Y occurrences of X the counter resets to 0

 

The obvious = way to do this is with a counter CF.

 

CREATE TABLE = xcounter1 (

         &= nbsp;      id uuid,

         &= nbsp;      someid int,

         &= nbsp;      count counter

) PRIMARY KEY (uid, someid)

 

This is how = I’ve always done it in the past, but I’ve been told to avoid = counters for various reasons, performance, consistency = etc..

I’m not too bothered = about 100% absolute consistency, however read performance is certainly a = big concern.

 

So I was thinking to avoid using counters I could do = something like this.

 

CREATE TABLE = xcounter2 (

         &= nbsp;      id uuid,

         &= nbsp;      someid int,

         &= nbsp;      time timeuuid

) PRIMARY KEY (uid, someid, time)

 

Then = retrieve all events and count in memory. Delete all id, someid records = once I hit Y.

 

Or I could

CREATE = TABLE xcounter3 (

         &= nbsp;      id uuid,

         &= nbsp;      someid int,

         &= nbsp;      time timeuuid,

         &= nbsp;      Ycount int

) PRIMARY KEY (uid, someid, time)

 

Insert a = ‘Ycount’ on each occurrence of the event.

Only retrieve the last Y value inserted on = reading

Then delete all records once = I hit the magic Y value.

 

 

Anyone have = any interesting thoughts or insight on what is likely to give me the = best read performance?

There will be = 100’s of someid to each id. Reads will be 5-10x the = writes.

 

 

Thanks,

 

Chris

------=_NextPart_000_0186_01CEF1D0.D898D7B0--