Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended Storage For MySQL and Postgres #51

Closed
ghost opened this issue Jul 3, 2022 · 2 comments
Closed

Recommended Storage For MySQL and Postgres #51

ghost opened this issue Jul 3, 2022 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 3, 2022

Hi,

Firstly thanks for this amazing crate. I intend to use this for primary keys in a MySQL and potentially Postgres database. How would you suggest I store these? Could I use binary or just use the 26-character representation? I have looked at this ulid/spec#25 but not sure how it relates to this implementation. Another option is converting them to UUIDs and storing them as native uuid types in the databases but not sure if this would retain the sorting information.

@dylanhart
Copy link
Owner

  • A binary format would be preferred since there is no ambiguity or duplication (like uppercase vs lowercase).
  • The binary format is smaller.
  • Converting to uuid and back is lossless, but the derived uuid will not have sensible version information.
  • The best way to compare is to test and measure performance.

@mqudsi
Copy link

mqudsi commented Aug 17, 2022

Note that MySQL has issues creating foreign keys against blob primary keys or keys of variable length. On Postgres, you can store ulids as uuid type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants