You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Gareth Collins <ga...@gmail.com> on 2013/04/13 08:05:37 UTC
Anyway To Query Just The Partition Key?
Hello,
If I have a cql3 table like this (I don't have a table with this data -
this is just for example):
create table (
surname text,
city text,
country text,
event_id timeuuid,
data text,
PRIMARY KEY ((surname, city, country),event_id));
there is no way of (easily) getting the set (or a subset) of partition
keys, is there (i.e. surname/city/country)? If I want easy access to do
queries to get a subset of the partition keys, I have to create another
table?
I am assuming yes but just making sure I am not missing something obvious
here.
thanks in advance,
Gareth
Re: Anyway To Query Just The Partition Key?
Posted by Sylvain Lebresne <sy...@datastax.com>.
What you want is https://issues.apache.org/jira/browse/CASSANDRA-4536 I
believe.
On Sat, Apr 13, 2013 at 8:16 PM, Gareth Collins
<ga...@gmail.com>wrote:
> Edward,
>
> Thanks for the response. This is what I thought. The only reason why I am
> doing it like this is that I don't know these partition keys in advance
> (otherwise I would design this differently). So when I need to insert data,
> it looks like I need to insert to both the data table and the table
> containing the partition keys. Good thing writes in Cassandra are
> idempotent...:)
>
> thanks again,
> Gareth
>
>
> On Sat, Apr 13, 2013 at 7:26 AM, Edward Capriolo <ed...@gmail.com>wrote:
>
>> You can 'list' or 'select *' the column family and you get them in a
>> pseudo random order. When you say subset it implies you might want a
>> specific range which is something this schema can not do.
>>
>>
>>
>>
>> On Sat, Apr 13, 2013 at 2:05 AM, Gareth Collins <
>> gareth.o.collins@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> If I have a cql3 table like this (I don't have a table with this data -
>>> this is just for example):
>>>
>>> create table (
>>> surname text,
>>> city text,
>>> country text,
>>> event_id timeuuid,
>>> data text,
>>> PRIMARY KEY ((surname, city, country),event_id));
>>>
>>> there is no way of (easily) getting the set (or a subset) of partition
>>> keys, is there (i.e. surname/city/country)? If I want easy access to do
>>> queries to get a subset of the partition keys, I have to create another
>>> table?
>>>
>>> I am assuming yes but just making sure I am not missing something
>>> obvious here.
>>>
>>> thanks in advance,
>>> Gareth
>>>
>>
>>
>
Re: Anyway To Query Just The Partition Key?
Posted by Gareth Collins <ga...@gmail.com>.
Edward,
Thanks for the response. This is what I thought. The only reason why I am
doing it like this is that I don't know these partition keys in advance
(otherwise I would design this differently). So when I need to insert data,
it looks like I need to insert to both the data table and the table
containing the partition keys. Good thing writes in Cassandra are
idempotent...:)
thanks again,
Gareth
On Sat, Apr 13, 2013 at 7:26 AM, Edward Capriolo <ed...@gmail.com>wrote:
> You can 'list' or 'select *' the column family and you get them in a
> pseudo random order. When you say subset it implies you might want a
> specific range which is something this schema can not do.
>
>
>
>
> On Sat, Apr 13, 2013 at 2:05 AM, Gareth Collins <
> gareth.o.collins@gmail.com> wrote:
>
>> Hello,
>>
>> If I have a cql3 table like this (I don't have a table with this data -
>> this is just for example):
>>
>> create table (
>> surname text,
>> city text,
>> country text,
>> event_id timeuuid,
>> data text,
>> PRIMARY KEY ((surname, city, country),event_id));
>>
>> there is no way of (easily) getting the set (or a subset) of partition
>> keys, is there (i.e. surname/city/country)? If I want easy access to do
>> queries to get a subset of the partition keys, I have to create another
>> table?
>>
>> I am assuming yes but just making sure I am not missing something obvious
>> here.
>>
>> thanks in advance,
>> Gareth
>>
>
>
Re: Anyway To Query Just The Partition Key?
Posted by Edward Capriolo <ed...@gmail.com>.
You can 'list' or 'select *' the column family and you get them in a pseudo
random order. When you say subset it implies you might want a specific
range which is something this schema can not do.
On Sat, Apr 13, 2013 at 2:05 AM, Gareth Collins
<ga...@gmail.com>wrote:
> Hello,
>
> If I have a cql3 table like this (I don't have a table with this data -
> this is just for example):
>
> create table (
> surname text,
> city text,
> country text,
> event_id timeuuid,
> data text,
> PRIMARY KEY ((surname, city, country),event_id));
>
> there is no way of (easily) getting the set (or a subset) of partition
> keys, is there (i.e. surname/city/country)? If I want easy access to do
> queries to get a subset of the partition keys, I have to create another
> table?
>
> I am assuming yes but just making sure I am not missing something obvious
> here.
>
> thanks in advance,
> Gareth
>
Re: Anyway To Query Just The Partition Key?
Posted by Gareth Collins <ga...@gmail.com>.
Thank you for the answer.
My apologies. I should have been clearer with my question.
Say for example, I have a 1000 partition keys and 10000 rows per partition
key I am trying to avoid bringing back 10 million rows to find the 1000
partition keys. I assume I cannot avoid bringing back the 10 million rows
(or at least an order of magnitude more than 1000 rows) without having
another table?
thanks,
Gareth
On Sat, Apr 13, 2013 at 4:13 AM, Jabbar Azam <aj...@gmail.com> wrote:
> With your example you can do an equality search with surname and city and
> then use "in" with country
>
> Eg. Select * from yourtable where surname="blah" and city="blah blah" and
> country in ("country1", "country2")
>
> Hope that helps
>
> Jabbar Azam
> On 13 Apr 2013 07:06, "Gareth Collins" <ga...@gmail.com> wrote:
>
>> Hello,
>>
>> If I have a cql3 table like this (I don't have a table with this data -
>> this is just for example):
>>
>> create table (
>> surname text,
>> city text,
>> country text,
>> event_id timeuuid,
>> data text,
>> PRIMARY KEY ((surname, city, country),event_id));
>>
>> there is no way of (easily) getting the set (or a subset) of partition
>> keys, is there (i.e. surname/city/country)? If I want easy access to do
>> queries to get a subset of the partition keys, I have to create another
>> table?
>>
>> I am assuming yes but just making sure I am not missing something obvious
>> here.
>>
>> thanks in advance,
>> Gareth
>>
>
Re: Anyway To Query Just The Partition Key?
Posted by Jabbar Azam <aj...@gmail.com>.
With your example you can do an equality search with surname and city and
then use "in" with country
Eg. Select * from yourtable where surname="blah" and city="blah blah" and
country in ("country1", "country2")
Hope that helps
Jabbar Azam
On 13 Apr 2013 07:06, "Gareth Collins" <ga...@gmail.com> wrote:
> Hello,
>
> If I have a cql3 table like this (I don't have a table with this data -
> this is just for example):
>
> create table (
> surname text,
> city text,
> country text,
> event_id timeuuid,
> data text,
> PRIMARY KEY ((surname, city, country),event_id));
>
> there is no way of (easily) getting the set (or a subset) of partition
> keys, is there (i.e. surname/city/country)? If I want easy access to do
> queries to get a subset of the partition keys, I have to create another
> table?
>
> I am assuming yes but just making sure I am not missing something obvious
> here.
>
> thanks in advance,
> Gareth
>