Skip to content

recommendation for creating stripe-like prefixed identifiers #80

@charlie-maloney

Description

@charlie-maloney

Hi,

Thanks for all your work on cuid2. I'm considering using this library as a way to generate IDs in our Postgres DB, and I had a couple questions regarding recommendations for usage in cuid2:

  1. I want to create stripe-like prefixed identifiers for my application (e.g. usr_ tz4a98xxat96iws9zmbrgj3a). Is this at as simple as concatenating the prefix with cuid ID or are there other considerations we must make?

  2. Would you recommend using this as the primary key in our DB? I see a lot of discussion around using monotonically increasing IDs (ints/big ints) as primary keys for performance reasons and having a separate entity ID for usage in APIs. My concerns with the latter approach are a) you still need to either index on the entity id or maintain a look-up table mapping entity IDs to primary keys and b) your primary keys in a sharded DB are no longer unique.

Any advice or considerations would be greatly appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions