Skip to content

Clarify primary keys, static columns vs. column families #6834

Open
@bra-fsn

Description

@bra-fsn

Exalate commented:

On https://www.cockroachlabs.com/docs/dev/column-families.html the example contains a table with one column as the primary key, the id:

CREATE TABLE test (
    id INT PRIMARY KEY,
    last_accessed TIMESTAMP,
    data BYTES,
    FAMILY f1 (id, last_accessed),
    FAMILY f2 (data)
);

The example then mixes never updated fields (id) with the frequently updated one last_accessed in one column family, putting the never modified data into f2.

For the first glance, it would be logical to group static (id and data) columns into one family and frequently modified ones to the other:

CREATE TABLE test (
    id INT PRIMARY KEY,
    last_accessed TIMESTAMP,
    data BYTES,
    FAMILY f1 (id, data),
    FAMILY f2 (last_accessed)
);

So could you please extend the current doc, explain and add more details about:

  • why putting id and last_accessed into one CF is recommended
  • what if there are more PK columns, should those be in the frequently modified CF in this case as well?

Jira Issue: DOC-462

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions