You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by kurt greaves <ku...@instaclustr.com> on 2018/02/01 05:46:13 UTC

Re: range queries on partition key supported?

>
> So that means more than one nodes can be selected to fulfill a range query
> based on the token, correct?


Yes. When doing a token range query Cassandra will need to send requests to
any node that owns part of the token range requested. This could be just
one set of replicas or more, depending on how your token ring is arranged.
You could avoid querying multiple nodes by limiting the token() calls to be
within one token range.

And, then entire partition on each node will be searched based on the
> clustering key (i.e. "time" in this case).

No. it will skip to the section of the partition with time = '12:00'.
Cassandra should be smart enough to avoid reading the whole partition.


On 31 January 2018 at 06:57, Tyagi, Preetika <pr...@intel.com>
wrote:

> So that means more than one nodes can be selected to fulfill a range query
> based on the token, correct?
>
> I was looking at this link: https://www.datastax.com/dev/
> blog/a-deep-look-to-the-cql-where-clause
>
> In the example query,
> SELECT * FROM numberOfRequests
>     WHERE token(cluster, date) > token('cluster1', '2015-06-03')
>     AND token(cluster, date) <= token('cluster1', '2015-06-05')
>     AND time = '12:00'
>
> More than one nodes might get picked for this token based range query.
> And, then entire partition on each node will be searched based on the
> clustering key (i.e. "time" in this case).
> Is my understanding correct?
>
> Thanks,
> Preetika
>
> -----Original Message-----
> From: J. D. Jordan [mailto:jeremiah.jordan@gmail.com]
> Sent: Tuesday, January 30, 2018 10:13 AM
> To: dev@cassandra.apache.org
> Subject: Re: range queries on partition key supported?
>
> A range query can be performed on the token of a partition key, not on the
> value.
>
> -Jeremiah
>
> > On Jan 30, 2018, at 12:21 PM, Tyagi, Preetika <pr...@intel.com>
> wrote:
> >
> > Hi All,
> >
> > I have a quick question on Cassandra's behavior in case of partition
> keys. I know that range queries are allowed in general, however, is it also
> allowed on partition keys as well? The partition key is used as an input to
> determine a node in a cluster, so I'm wondering how one can possibly
> perform range query on that.
> >
> > Thanks,
> > Preetika
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: dev-help@cassandra.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: dev-help@cassandra.apache.org
>
>

RE: range queries on partition key supported?

Posted by "Tyagi, Preetika" <pr...@intel.com>.
Thank you, Kurt. Just one more clarification.

And, then entire partition on each node will be searched based on the
> clustering key (i.e. "time" in this case).

No. it will skip to the section of the partition with time = '12:00'.
Cassandra should be smart enough to avoid reading the whole partition.

Yeah, that seems to correct. I probably didn't phrase it correctly.

Now let's assume a specific node is selected based on the token range and we need to look up for the data with time='12:00' within the partition which was obviously within token range.
Now on this node, there may be more than one partitions (let's take two partitions for example) which qualify for this token range. In that case, these two partitions will need to be looked up to get the data with the given time = 12:00.
So I'm wondering how these two partitions will be looked up on this node. How the request query would look like on this node to get these partitions?
Does it make sense? Do you think I'm missing something?

Thanks,
Preetika

-----Original Message-----
From: kurt greaves [mailto:kurt@instaclustr.com] 
Sent: Wednesday, January 31, 2018 9:46 PM
To: dev@cassandra.apache.org
Subject: Re: range queries on partition key supported?

>
> So that means more than one nodes can be selected to fulfill a range 
> query based on the token, correct?


Yes. When doing a token range query Cassandra will need to send requests to any node that owns part of the token range requested. This could be just one set of replicas or more, depending on how your token ring is arranged.
You could avoid querying multiple nodes by limiting the token() calls to be within one token range.

And, then entire partition on each node will be searched based on the
> clustering key (i.e. "time" in this case).

No. it will skip to the section of the partition with time = '12:00'.
Cassandra should be smart enough to avoid reading the whole partition.


On 31 January 2018 at 06:57, Tyagi, Preetika <pr...@intel.com>
wrote:

> So that means more than one nodes can be selected to fulfill a range 
> query based on the token, correct?
>
> I was looking at this link: https://www.datastax.com/dev/ 
> blog/a-deep-look-to-the-cql-where-clause
>
> In the example query,
> SELECT * FROM numberOfRequests
>     WHERE token(cluster, date) > token('cluster1', '2015-06-03')
>     AND token(cluster, date) <= token('cluster1', '2015-06-05')
>     AND time = '12:00'
>
> More than one nodes might get picked for this token based range query.
> And, then entire partition on each node will be searched based on the 
> clustering key (i.e. "time" in this case).
> Is my understanding correct?
>
> Thanks,
> Preetika
>
> -----Original Message-----
> From: J. D. Jordan [mailto:jeremiah.jordan@gmail.com]
> Sent: Tuesday, January 30, 2018 10:13 AM
> To: dev@cassandra.apache.org
> Subject: Re: range queries on partition key supported?
>
> A range query can be performed on the token of a partition key, not on 
> the value.
>
> -Jeremiah
>
> > On Jan 30, 2018, at 12:21 PM, Tyagi, Preetika 
> > <pr...@intel.com>
> wrote:
> >
> > Hi All,
> >
> > I have a quick question on Cassandra's behavior in case of partition
> keys. I know that range queries are allowed in general, however, is it 
> also allowed on partition keys as well? The partition key is used as 
> an input to determine a node in a cluster, so I'm wondering how one 
> can possibly perform range query on that.
> >
> > Thanks,
> > Preetika
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: dev-help@cassandra.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: dev-help@cassandra.apache.org
>
>