8000 [Uid] Add a note on the use of entity primary keys · Issue #19705 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Uid] Add a note on the use of entity primary keys #19705

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

Closed
seb-jean opened this issue Mar 24, 2024 · 6 comments
Closed

[Uid] Add a note on the use of entity primary keys #19705

seb-jean opened this issue Mar 24, 2024 · 6 comments
Labels
hasPR A Pull Request has already been submitted for this issue. Uid
Milestone

Comments

@seb-jean
Copy link
Contributor
seb-jean commented Mar 24, 2024

It would be interesting to add a note on the use U*id values for primary key in an entity.
This use is bad practice.
What do you think ?

@carsonbot carsonbot added the Uid label Mar 24, 2024
@javiereguiluz
Copy link
Member

Can you please share some resources where they explain that this is a bad practice and the reasons for it?

Also, let's keep in mind that we have lots of different UIDs, so maybe some are bad for PKs but not others. Thanks!

@seb-jean
Copy link
Contributor Author
seb-jean commented Mar 26, 2024

For my part, I use ULIDs.

Yes, there is the comment symfony/symfony#41544 (comment).

What do you think ?

@javiereguiluz
Copy link
Member

I'm afraid that's not enough. We'd need good resources that provide reasoned arguments to prove that this is a bad practice. E.g. if it's bad for performance reasons, show a good benchmark, etc. Thanks.

@seb-jean
Copy link
Contributor Author

I don't have any resources, benchmarks, etc.

@gnito-org
Copy link
Contributor

If you use ULID, then you can also use UUID V7.

Like ULID, UUID V7 also provides monotonically increasing values that are lexicographically sortable.

I've been using V7 as primary keys without any issues.

@javiereguiluz javiereguiluz added this to the 6.4 milestone Apr 12, 2024
@javiereguiluz javiereguiluz added the hasPR A Pull Request has already been submitted for this issue. label Apr 12, 2024
@javiereguiluz
Copy link
Member

I search about this and read a lot of different posts. There seems to be a consensus on the drawbacks, so I propose to add that in #19783.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. Uid
Projects
None yet
Development

No branches or pull requests

4 participants
0