Skip to content

Use UUID for table primary keys #13

@orthomind

Description

@orthomind

I'd like to suggest (and I may be happy to look at submitting a PR request myself for) using UUID's for primary keys rather than int's. One of cockroachdb's main advantage is its ability to scale horizontally, but using keys like this prevent that from being fully utilised if it's ever needed.

By using UUID's, nodes can more easily share workload. While perhaps not needed for this project (I don't see it needing the kind of scale that cdb offers, but I may not understand well), changes to database design are easiest to do now before the project is in production, and helps future-proof the design.

From the doc notes (https://www.cockroachlabs.com/docs/stable/serial.html):

In most cases, we recommend using the UUID data type with the gen_random_uuid() function as the default value, which generates 128-bit values (larger than SERIAL's maximum of 64 bits) and more uniformly scatters them across all of a table's underlying key-value ranges. UUIDs ensure more effectively that multiple nodes share the insert load when a UUID column is used in an index or primary key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions