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 C2BBC177BE for ; Wed, 27 May 2015 04:59:48 +0000 (UTC) Received: (qmail 72751 invoked by uid 500); 27 May 2015 04:59:46 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 72703 invoked by uid 500); 27 May 2015 04:59:45 -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 72693 invoked by uid 99); 27 May 2015 04:59:45 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 May 2015 04:59:45 +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 7620318275B for ; Wed, 27 May 2015 04:59:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.75 X-Spam-Level: X-Spam-Status: No, score=0.75 tagged_above=-999 required=6.31 tests=[KAM_INFOUSMEBIZ=0.75, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Oa3633eiq02s for ; Wed, 27 May 2015 04:59:34 +0000 (UTC) Received: from relay12.nicmail.ru (relay12.nicmail.ru [195.208.5.7]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 0D3AE209DC for ; Wed, 27 May 2015 04:59:33 +0000 (UTC) Received: from [31.177.73.205] (port=54749 helo=nicmail.ru) by f06.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1YxTRP-000Omv-1E; Wed, 27 May 2015 07:59:43 +0300 Received: from [188.123.241.177] (account mail@eax.me HELO fujitsu) by fcgp27.nicmail.ru (CommuniGate Pro SMTP 5.2.3) with ESMTPSA id 7928113; Wed, 27 May 2015 07:59:26 +0300 Date: Wed, 27 May 2015 07:56:21 +0300 From: Eax Melanhovich To: Tyler Hobbs Cc: user@cassandra.apache.org Subject: Re: A few stupid questions... Message-ID: <20150527075621.43b85d9b@fujitsu> In-Reply-To: References: <20150526220045.186b2b2d@fujitsu> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Thank you! On Tue, 26 May 2015 15:45:01 -0500 Tyler Hobbs wrote: > On Tue, May 26, 2015 at 2:00 PM, Eax Melanhovich wrote: > > > > > First. Lets say I have a table (field1, field2, field3, field4), > > where (field1, field2) is a primary key and field1 is partition > > key. There is a secondary index for field3 column. Do I right > > understand that in this case query like: > > > > select ... from my_table where field1 = 123 and field3 > '...'; > > > > ... would be quite efficient, i.e. request would be send only to one > > node, not the whole cluster? > > > > You are correct that it would only query one node (or one set of > replicas, if RF > 1 and CL > 1) due to the partition key being > restricted. However, using '>' for the operator on the indexed > column forces Cassandra to scan the partition instead of using the > index, because secondary indexes only support '=' operations. If you > care about performance, you're probably better off creating a > dedicated table to serve this type of query, as described here: > http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling > > > > > > Second. Lets say there is some data that almost never changes but is > > read all the time. E.g. information about smiles in social network. > > Or current sessions. In this case would Cassandra cache "hot" data > > in memtable? Or such data should be stored somewhere else, i.e. > > Redis or Couchbase? > > > Memtables are only used for buffering writes, not for caching read > data. Cassandra does have several layers of caching though. > Frequently read data will end up in the key cache and the OS page > cache, making reads quite efficient. Optionally, you can also enable > the row cache. Since you're almost never modifying the data, the row > cache is actually a decent fit, although I recommend testing it > heavily with your use case for stability. The best way to find out if > your performance is good enough is to benchmark it with your own > usecase. > > -- Best regards, Eax Melanhovich http://eax.me/