You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Sloot, Hans-Peter" <ha...@atos.net> on 2013/02/27 14:03:25 UTC

range queries

Hello,

I have what is perhaps a silly question.

Column family other2 which has a varchar as primary key and a uuid column.
I  have inserted 2000 rows

All rows keys start with 'nl' followed by other characters.

To my surprise when I do  : select count(*) from other2 where key > 'z';

It shows :

 count
-------
  1947

All rows start with a character smaller than 1.

But it becomes even more strange:

cqlsh:demo> select count(*) from other2 where key > 'zz';
 count
-------
  1415

cqlsh:demo> select count(*) from other2 where key > 'zzz';
 count
-------
  1820  < -- now the row count has even increased.

What am I doing wrong here?

Regards







Dit bericht is vertrouwelijk en kan geheime informatie bevatten enkel bestemd voor de geadresseerde. Indien dit bericht niet voor u is bestemd, verzoeken wij u dit onmiddellijk aan ons te melden en het bericht te vernietigen. Aangezien de integriteit van het bericht niet veilig gesteld is middels verzending via internet, kan Atos Nederland B.V. niet aansprakelijk worden gehouden voor de inhoud daarvan. Hoewel wij ons inspannen een virusvrij netwerk te hanteren, geven wij geen enkele garantie dat dit bericht virusvrij is, noch aanvaarden wij enige aansprakelijkheid voor de mogelijke aanwezigheid van een virus in dit bericht. Op al onze rechtsverhoudingen, aanbiedingen en overeenkomsten waaronder Atos Nederland B.V. goederen en/of diensten levert zijn met uitsluiting van alle andere voorwaarden de Leveringsvoorwaarden van Atos Nederland B.V. van toepassing. Deze worden u op aanvraag direct kosteloos toegezonden.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Nederland B.V. group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted. On all offers and agreements under which Atos Nederland B.V. supplies goods and/or services of whatever nature, the Terms of Delivery from Atos Nederland B.V. exclusively apply. The Terms of Delivery shall be promptly submitted to you on your request.

Atos Nederland B.V. / Utrecht
KvK Utrecht 30132762

Re: range queries

Posted by Alain RODRIGUEZ <ar...@gmail.com>.
Things you can find searching on the web :

http://wiki.apache.org/cassandra/DataModel#Range_queries


2013/2/27 Alain RODRIGUEZ <ar...@gmail.com>

> "What am I doing wrong here?"
>
> You are probably using a RandomPartitioner (or Murmur3Partitioner) which
> randomize keys to avoid hot spots.
>
> Basically, you just can't use range query because 'nlxxxxxxxxxx' is
> stored as md5('nlxxxxxxxxxx'). You should better modify your model to use
> column slice, which are ordered.
>
> An other solution, which is not recommended at all because it leads to hot
> spots, is to use an OrderedPreservingPartitioner. But once again, I think
> you shouldn't do it.
>
> I have no time to go deeper in my explanation but with what I already told
> you, you should be able to find out by yourself more details if needed.
>
> Alain
>
>
> 2013/2/27 Sloot, Hans-Peter <ha...@atos.net>
>
> Hello,
>>
>> I have what is perhaps a silly question.
>>
>> Column family other2 which has a varchar as primary key and a uuid column.
>> I  have inserted 2000 rows
>>
>> All rows keys start with 'nl' followed by other characters.
>>
>> To my surprise when I do  : select count(*) from other2 where key > 'z';
>>
>> It shows :
>>
>>  count
>> -------
>>   1947
>>
>> All rows start with a character smaller than 1.
>>
>> But it becomes even more strange:
>>
>> cqlsh:demo> select count(*) from other2 where key > 'zz';
>>  count
>> -------
>>   1415
>>
>> cqlsh:demo> select count(*) from other2 where key > 'zzz';
>>  count
>> -------
>>   1820  < -- now the row count has even increased.
>>
>> What am I doing wrong here?
>>
>> Regards
>>
>>
>>
>>
>>
>>
>>
>> Dit bericht is vertrouwelijk en kan geheime informatie bevatten enkel
>> bestemd voor de geadresseerde. Indien dit bericht niet voor u is bestemd,
>> verzoeken wij u dit onmiddellijk aan ons te melden en het bericht te
>> vernietigen. Aangezien de integriteit van het bericht niet veilig gesteld
>> is middels verzending via internet, kan Atos Nederland B.V. niet
>> aansprakelijk worden gehouden voor de inhoud daarvan. Hoewel wij ons
>> inspannen een virusvrij netwerk te hanteren, geven wij geen enkele garantie
>> dat dit bericht virusvrij is, noch aanvaarden wij enige aansprakelijkheid
>> voor de mogelijke aanwezigheid van een virus in dit bericht. Op al onze
>> rechtsverhoudingen, aanbiedingen en overeenkomsten waaronder Atos Nederland
>> B.V. goederen en/of diensten levert zijn met uitsluiting van alle andere
>> voorwaarden de Leveringsvoorwaarden van Atos Nederland B.V. van toepassing.
>> Deze worden u op aanvraag direct kosteloos toegezonden.
>>
>> This e-mail and the documents attached are confidential and intended
>> solely for the addressee; it may also be privileged. If you receive this
>> e-mail in error, please notify the sender immediately and destroy it. As
>> its integrity cannot be secured on the Internet, the Atos Nederland B.V.
>> group liability cannot be triggered for the message content. Although the
>> sender endeavours to maintain a computer virus-free network, the sender
>> does not warrant that this transmission is virus-free and will not be
>> liable for any damages resulting from any virus transmitted. On all offers
>> and agreements under which Atos Nederland B.V. supplies goods and/or
>> services of whatever nature, the Terms of Delivery from Atos Nederland B.V.
>> exclusively apply. The Terms of Delivery shall be promptly submitted to you
>> on your request.
>>
>> Atos Nederland B.V. / Utrecht
>> KvK Utrecht 30132762
>>
>
>

Re: range queries

Posted by Alain RODRIGUEZ <ar...@gmail.com>.
"What am I doing wrong here?"

You are probably using a RandomPartitioner (or Murmur3Partitioner) which
randomize keys to avoid hot spots.

Basically, you just can't use range query because 'nlxxxxxxxxxx' is stored
as md5('nlxxxxxxxxxx'). You should better modify your model to use column
slice, which are ordered.

An other solution, which is not recommended at all because it leads to hot
spots, is to use an OrderedPreservingPartitioner. But once again, I think
you shouldn't do it.

I have no time to go deeper in my explanation but with what I already told
you, you should be able to find out by yourself more details if needed.

Alain


2013/2/27 Sloot, Hans-Peter <ha...@atos.net>

> Hello,
>
> I have what is perhaps a silly question.
>
> Column family other2 which has a varchar as primary key and a uuid column.
> I  have inserted 2000 rows
>
> All rows keys start with 'nl' followed by other characters.
>
> To my surprise when I do  : select count(*) from other2 where key > 'z';
>
> It shows :
>
>  count
> -------
>   1947
>
> All rows start with a character smaller than 1.
>
> But it becomes even more strange:
>
> cqlsh:demo> select count(*) from other2 where key > 'zz';
>  count
> -------
>   1415
>
> cqlsh:demo> select count(*) from other2 where key > 'zzz';
>  count
> -------
>   1820  < -- now the row count has even increased.
>
> What am I doing wrong here?
>
> Regards
>
>
>
>
>
>
>
> Dit bericht is vertrouwelijk en kan geheime informatie bevatten enkel
> bestemd voor de geadresseerde. Indien dit bericht niet voor u is bestemd,
> verzoeken wij u dit onmiddellijk aan ons te melden en het bericht te
> vernietigen. Aangezien de integriteit van het bericht niet veilig gesteld
> is middels verzending via internet, kan Atos Nederland B.V. niet
> aansprakelijk worden gehouden voor de inhoud daarvan. Hoewel wij ons
> inspannen een virusvrij netwerk te hanteren, geven wij geen enkele garantie
> dat dit bericht virusvrij is, noch aanvaarden wij enige aansprakelijkheid
> voor de mogelijke aanwezigheid van een virus in dit bericht. Op al onze
> rechtsverhoudingen, aanbiedingen en overeenkomsten waaronder Atos Nederland
> B.V. goederen en/of diensten levert zijn met uitsluiting van alle andere
> voorwaarden de Leveringsvoorwaarden van Atos Nederland B.V. van toepassing.
> Deze worden u op aanvraag direct kosteloos toegezonden.
>
> This e-mail and the documents attached are confidential and intended
> solely for the addressee; it may also be privileged. If you receive this
> e-mail in error, please notify the sender immediately and destroy it. As
> its integrity cannot be secured on the Internet, the Atos Nederland B.V.
> group liability cannot be triggered for the message content. Although the
> sender endeavours to maintain a computer virus-free network, the sender
> does not warrant that this transmission is virus-free and will not be
> liable for any damages resulting from any virus transmitted. On all offers
> and agreements under which Atos Nederland B.V. supplies goods and/or
> services of whatever nature, the Terms of Delivery from Atos Nederland B.V.
> exclusively apply. The Terms of Delivery shall be promptly submitted to you
> on your request.
>
> Atos Nederland B.V. / Utrecht
> KvK Utrecht 30132762
>