incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Lebresne <sylv...@datastax.com>
Subject Re: Performance problem with large wide row inserts using CQL
Date Mon, 24 Feb 2014 10:47:16 GMT
>
>
>
>>
>>> I still have some questions regarding the mapping. Please bear with me
>>> if these are stupid questions. I am quite new to Cassandra.
>>>
>>> The basic cassandra data model for a keyspace is something like this,
>>> right?
>>>
>>> SortedMap<byte[], SortedMap<byte[], Pair<Long, byte[]>>
>>>                  ^ row key. determines which server(s) the rest is
>>> stored on
>>>                                              ^ column key
>>>                                                                ^
>>> timestamp (latest one wins)
>>>
>>> ^ value (can be size 0)
>>>
>>
>> It's a reasonable way to think of how things are stored internally, yes.
>> Though as DuyHai mentioned, the first map is really sorting by token and in
>> general that means you use mostly the sorting of the second map concretely.
>>
>>
> Yes, understood.
>
> So the first SortedMap is sorted on some kind of hash of the actual key to
> make sure the data gets evenly distributed along the nodes? What if my key
> is already a good hash: is there a way to use an identity function as a
> hash function (in CQL)?
>

It's possible, yes. The hash function we're talking about is what Cassandra
calls "the partitioner". You configure the partitioner in the yaml config
file and there is one partitioner, ByteOrderedPartitioner, that is
basically the identify function.
We however usually discourage user for using it because the partitioner is
global to a cluster and cannot be changed (you basically pick it at cluster
creation time and are stuck with it until the end of time), and since
ByteOrderedPartitioner can easily lead to hotspot in the data distribution
if you're not careful...For those reasons, the default partitioner is also
much more tested, and I can't remember anyone mentioning the partitioner
has been a bottleneck.

--
Sylvain


>
>
>>
>>> So if I have a table like the one in my benchmark (using blobs)
>>>
>>> CREATE TABLE IF NOT EXISTS test.wide (
>>>   time blob,
>>>   name blob,
>>>   value blob,
>>>   PRIMARY KEY (time,name))
>>>   WITH COMPACT STORAGE
>>>
>>> From reading http://www.datastax.com/dev/blog/thrift-to-cql3 it seems
>>> that
>>>
>>> - time maps to the row key and name maps to the column key without any
>>> overhead
>>> - value directly maps to value in the model above without any prefix
>>>
>>> is that correct, or is there some overhead involved in CQL over the raw
>>> model as described above? If so, where exactly?
>>>
>>
>> That's correct.
>> For completeness sake, if you were to remove the COMPACT STORAGE, there
>> would be some overhead in how it maps to the underlying column key, but
>> that overhead would buy you much more flexibility in how you could evolve
>> this table schema (you could add more CQL columns later if needs be, have
>> collections or have static columns following CASSANDRA-6561 that comes in
>> 2.0.6; none of which you can have with COMPACT STORAGE). Note that it's
>> perfectly fine to use COMPACT STORAGE if you know you don't and won't need
>> the additional flexibility, but I generally advise people to actually check
>> first that using COMPACT STORAGE does make a concrete and meaningful
>> difference for their use case (be careful with premature optimization
>> really).
>>
>
> In this case I am confident that the schema will not change. But there
> will be other tables built from the same data where I am not going to use
> compact storage.
>
> cheers,
>
> RĂ¼diger
>

Mime
View raw message