You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sandor Molnar <sm...@kinamik.com> on 2010/09/16 15:14:24 UTC

Indexing&Locking in Cassandra

Hello,

I have a few questions about indexing and locking in Cassandra:
- if I understood well only row level indexing exists prior to v0.7. I mean only the primary keys are indexed. Is that true?
- is it possible to use composite primary keys? For instance I have a user object: User(name,birthday,gender,address) and I want to have the (name,birthday) columns as PK. Can I do? If yes, how?
- does Cassandra support CF (table) level locking? Couls someone explain me/provide a link how?

Thanks in advance,
Sandor

RE: Indexing&Locking in Cassandra

Posted by Sandor Molnar <sm...@kinamik.com>.
Thanks for your fast answer.
Regarding to the composite keys: that's what I thought by default I just needed some confirmation. Unfortunately I can not use this approach in our application so I will figure out something else.
I will check out Zookeeper to see if I can use it.

Thanks again!

Hello,

> I have a few questions about indexing and locking in Cassandra:
> - if I understood well only row level indexing exists prior to v0.7. I mean only the primary keys are indexed. Is that true?

Yes and no. The row name is the key which you use to fetch the row
from cassandra. There are methods to iterate thru rows but that's not
efficient and should be used only in batch operations. Columns inside
rows are sorted by their names so they are also indexes as you use the
column name to fetch the contents of the column. If you want to index
data by other ways you need to build your own application code which
maintains such indexes and the upcoming 0.7 version will bring some
handy features which makes the coders job much easier.

> - is it possible to use composite primary keys? For instance I have a user object: User(name,birthday,gender,address) and I want to have the (name,birthday) columns as PK. Can I do? If yes, how?

You can always create your row key as a string like "$name_$birthday".
Did this answer to your question?

> - does Cassandra support CF (table) level locking? Couls someone explain me/provide a link how?

No, cassandra doesn't have any locking capabilities. You can always
use some external locking mechanism like zookeeper
[http://hadoop.apache.org/zookeeper/] or implement your own sollution
on top of cassandra (not recommended as it's quite hard to get it
correctly).

 - Juho Mäkinen / Garo



Re: Indexing&Locking in Cassandra

Posted by Juho Mäkinen <ju...@gmail.com>.
Hello,

> I have a few questions about indexing and locking in Cassandra:
> - if I understood well only row level indexing exists prior to v0.7. I mean only the primary keys are indexed. Is that true?

Yes and no. The row name is the key which you use to fetch the row
from cassandra. There are methods to iterate thru rows but that's not
efficient and should be used only in batch operations. Columns inside
rows are sorted by their names so they are also indexes as you use the
column name to fetch the contents of the column. If you want to index
data by other ways you need to build your own application code which
maintains such indexes and the upcoming 0.7 version will bring some
handy features which makes the coders job much easier.

> - is it possible to use composite primary keys? For instance I have a user object: User(name,birthday,gender,address) and I want to have the (name,birthday) columns as PK. Can I do? If yes, how?

You can always create your row key as a string like "$name_$birthday".
Did this answer to your question?

> - does Cassandra support CF (table) level locking? Couls someone explain me/provide a link how?

No, cassandra doesn't have any locking capabilities. You can always
use some external locking mechanism like zookeeper
[http://hadoop.apache.org/zookeeper/] or implement your own sollution
on top of cassandra (not recommended as it's quite hard to get it
correctly).

 - Juho Mäkinen / Garo