Home / Companies / Cockroach Labs / Blog / Post Details
Content Deep Dive

How Online Primary Key Changes Work in CockroachDB

Blog post from Cockroach Labs

Post Details
Company
Date Published
Author
Rohan Yadav
Word Count
2,503
Language
English
Hacker News Points
22
Summary

CockroachDB now supports online primary key changes, allowing users to change the primary key of a table while performing read and write operations on the table. This feature makes it easier to transition an application from being single-region to multi-region or iterate on the schema of an application with no downtime. The implementation involves building new primary indexes along with their dependent indexes, swapping out the old primary key for the new one, and dropping the old primary key and indexes. This process ensures that all nodes in the system either view the target table as completely before or after the primary key change, maintaining data consistency and correctness during the transition.