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 8236519BE6 for ; Thu, 10 Mar 2016 15:42:45 +0000 (UTC) Received: (qmail 38803 invoked by uid 500); 10 Mar 2016 15:42:42 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 38754 invoked by uid 500); 10 Mar 2016 15:42:42 -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 38744 invoked by uid 99); 10 Mar 2016 15:42:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2016 15:42:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 131C9180535 for ; Thu, 10 Mar 2016 15:42:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.198 X-Spam-Level: * X-Spam-Status: No, score=1.198 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 281h_Fur0FdS for ; Thu, 10 Mar 2016 15:42:39 +0000 (UTC) Received: from mail-vk0-f44.google.com (mail-vk0-f44.google.com [209.85.213.44]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 01FA05F572 for ; Thu, 10 Mar 2016 15:42:39 +0000 (UTC) Received: by mail-vk0-f44.google.com with SMTP id c3so99903822vkb.3 for ; Thu, 10 Mar 2016 07:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=5b0ep5vT/eu6crfqd32LBQwuKIo7LSseNFJW7NYW+co=; b=mcURMr59vLx81EE/lksQvmunxjepM5OPGqJNFM5p+wNYmQS/bIgYQZyY4YI/P7kvt9 U5x3FTscOYksRb3pUHMdvQwgwlXC+mSMY08dHiwOlRBLJ7wGm72TOlpfEHqxVQeTG64j XjLu8GIjE4bx+0hTs7rbdGPpeMlm8y7oQt7z9Y0j5RziLn9VsAPlJWplsZ8oSf6v8X82 Ut2m3XhHB+r8YWW6IfpcM0A+B389Y52eYJPKJJCvjYVM4xBBiLY+bpXJQO5PIpPMzJHF wVx3nYfrintTsCvsM2xZdiDVSawPXEu4/jMfK9tBze/jWgQf7lbHA7dLuwaeObUXb64o ItZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=5b0ep5vT/eu6crfqd32LBQwuKIo7LSseNFJW7NYW+co=; b=byBfNIASchGjGwfWo1+iOsHIxzmGE1jFkJ23CDHHwgIf1QF69dFBLrZ4ORAjCq/DYX a5orDcakcz1hguTGkfYisJD217RqSG7dVWWJta3ICKWitohbqDIbCZNEnJicBgpS968M N064xr0Aqb8Vw/nDUHoi1mAoh0lGOYY5N9RzgKit9VEA3m2WBklM5Z4xPW2YTWpUvlkm XiCkXfJyU0YxMUMwp0gznLoS7DsEEAXSwOZ+2gWiTgfZy1L7wfBMuDXgsf7Ve4782cHD x65eMHgiF92vEao7CUcMF6xSDIH3S2AvnG2FnXXb0J0MmnJ4IkqJ9cCIhAOjSKTuJeKm 3KIQ== X-Gm-Message-State: AD7BkJJvzZUbQTO9aAXI0iA0HF/wCipJy+X0lvckP49r9s3F41PKLK8cglL6/m/8PMBU9s1Em5Jc2CxeNK4RmA== MIME-Version: 1.0 X-Received: by 10.31.141.75 with SMTP id p72mr4281780vkd.13.1457624558063; Thu, 10 Mar 2016 07:42:38 -0800 (PST) Received: by 10.31.54.13 with HTTP; Thu, 10 Mar 2016 07:42:38 -0800 (PST) In-Reply-To: <1954956784.7708782.1457618067317.JavaMail.yahoo@mail.yahoo.com> References: <1954956784.7708782.1457618067317.JavaMail.yahoo.ref@mail.yahoo.com> <1954956784.7708782.1457618067317.JavaMail.yahoo@mail.yahoo.com> Date: Thu, 10 Mar 2016 10:42:38 -0500 Message-ID: Subject: Re: Strategy for dividing wide rows beyond just adding to the partition key From: Jack Krupansky To: user@cassandra.apache.org, Jason Kania Content-Type: multipart/alternative; boundary=001a11426560ffd585052db3a969 --001a11426560ffd585052db3a969 Content-Type: text/plain; charset=UTF-8 There is an effort underway to support wider rows: https://issues.apache.org/jira/browse/CASSANDRA-9754 This won't help you now though. Even with that improvement you still may need a more optimal data model since large-scale scanning/filtering is always a very bad idea with Cassandra. The data modeling methodology for Cassandra dictates that queries drive the data model and that each form of query requires a separate table ("query table.") Materialized view can automate that process for a lot of cases, but in any case it does sound as if some of your queries do require additional tables. As a general proposition, Cassandra should not be used for heavy filtering - query tables with the filtering criteria baked into the PK is the way to go. -- Jack Krupansky On Thu, Mar 10, 2016 at 8:54 AM, Jason Kania wrote: > Hi, > > We have sensor input that creates very wide rows and operations on these > rows have started to timeout regulary. We have been trying to find a > solution to dividing wide rows but keep hitting limitations that move the > problem around instead of solving it. > > We have a partition key consisting of a sensorUnitId and a sensorId and > use a time field to access each column in the row. We tried adding a time > based entry, timeShardId, to the partition key that consists of the year > and week of year during which the reading was taken. This works for a > number of queries but for scanning all the readings against a particular > sensorUnitId and sensorId combination, we seem to be stuck. > > We won't know the range of valid values of the timeShardId for a given > sensorUnitId and sensorId combination so would have to write to an > additional table to track the valid timeShardId. We suspect this would > create tombstone accumulation problems given the number of updates required > to the same row so haven't tried this option. > > Alternatively, we hit a different bottleneck in the form of SELECT > DISTINCT in trying to directly access the partition keys. Since SELECT > DISTINCT does not allow for a where clause to filter on the partition key > values, we have to filter several hundred thousand partition keys just to > find those related to the relevant sensorUnitId and sensorId. This problem > will only grow worse for us. > > Are there any other approaches that can be suggested? We have been looking > around, but haven't found any references beyond the initial suggestion to > add some sort of shard id to the partition key to handle wide rows. > > Thanks, > > Jason > --001a11426560ffd585052db3a969 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
There is an effort underway to support wider rows:

This won'= t help you now though. Even with that improvement you still may need a more= optimal data model since large-scale scanning/filtering is always a very b= ad idea with Cassandra.

The data modeling methodol= ogy for Cassandra dictates that queries drive the data model and that each = form of query requires a separate table ("query table.") Material= ized view can automate that process for a lot of cases, but in any case it = does sound as if some of your queries do require additional tables.

As a general proposition, Cassandra should not be used fo= r heavy filtering - query tables with the filtering criteria baked into the= PK is the way to go.

=
-- J= ack Krupansky

On Thu, Mar 10, 2016 at 8:54 AM, Jason Kania= <jason.kania@ymail.com> wrote:
Hi,

We have sensor input that creat= es very wide rows and operations on these rows have started to timeout regu= lary. We have been trying to find a solution to dividing wide rows but keep= hitting limitations that move the problem around instead of solving it.

We have a partition key consisting of a = sensorUnitId and a sensorId and use a time field to access each column in t= he row. We tried adding a time based entry, timeShardId, to the partition k= ey that consists of the year and week of year during which the reading was = taken. This works for a number of queries but for scanning all the readings= against a particular sensorUnitId and sensorId combination, we seem to be = stuck.

We won't know t= he range of valid values of the timeShardId for a given sensorUnitId and se= nsorId combination so would have to write to an additional table to track t= he valid timeShardId. We suspect this would create tombstone accumulation p= roblems given the number of updates required to the same row so haven't= tried this option.

Al= ternatively, we hit a different bottleneck in the form of SELECT DISTINCT i= n trying to directly access the partition keys. Since SELECT DISTINCT does = not allow for a where clause to filter on the partition key values, we have= to filter several hundred thousand partition keys just to find those relat= ed to the relevant sensorUnitId and sensorId. This problem will only grow w= orse for us.

Are there= any other approaches that can be suggested? We have been looking around, b= ut haven't found any references beyond the initial suggestion to add so= me sort of shard id to the partition key to handle wide rows.

Thanks,

Jason

--001a11426560ffd585052db3a969--