You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jimmy Lin <y2...@gmail.com> on 2013/09/27 18:05:44 UTC

changing the primary key type of a table

hi,
we have a table that its primary key is uuid type. Now we decide that we
need to use text type as it is more flexible for our application.

#1
is there any downside using text as primary key? any performance impact on
the partition ?

#2
There is no way to alter a table's primary key with a cql command, that is
what i have read, migrating to a new table seems to be the only way.
Is there any good recommendation how to do this? cqlsh copy or jsonsttable
seems like will all result in same datatype as before.

thanks

Re: changing the primary key type of a table

Posted by Aaron Morton <aa...@thelastpickle.com>.
> is there any downside using text as primary key? any performance impact on the partition ? 
Nope. 

> There is no way to alter a table's primary key with a cql command, that is what i have read, migrating to a new table seems to be the only way.
Yup.

> Is there any good recommendation how to do this? cqlsh copy or jsonsttable seems like will all result in same datatype as before.
* create the new table
* backfill data to it while your app is writing to both the old and the new
* stop writing to the old
* drop the old. 


Cheers

-----------------
Aaron Morton
New Zealand
@aaronmorton

Co-Founder & Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 28/09/2013, at 4:05 AM, Jimmy Lin <y2...@gmail.com> wrote:

> hi,
> we have a table that its primary key is uuid type. Now we decide that we need to use text type as it is more flexible for our application.
>  
> #1
> is there any downside using text as primary key? any performance impact on the partition ? 
>  
> #2
> There is no way to alter a table's primary key with a cql command, that is what i have read, migrating to a new table seems to be the only way.
> Is there any good recommendation how to do this? cqlsh copy or jsonsttable seems like will all result in same datatype as before.
>  
> thanks
>