[GH-ISSUE #1189] PostgreSQL backend doesn't use the "uuid" type #836

Closed
opened 2026-03-03 02:03:46 +03:00 by kerem · 6 comments
Owner

Originally created by @pounard on GitHub (Oct 16, 2020).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1189

Hello, I noticed that PostgreSQL schema doesn't use the uuid type for UUIDs, is there a reason for this ?

Originally created by @pounard on GitHub (Oct 16, 2020). Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1189 Hello, I noticed that PostgreSQL schema doesn't use the `uuid` type for UUIDs, is there a reason for this ?
Author
Owner

@BlackDex commented on GitHub (Oct 16, 2020):

I actually have no idea.
I do see we use varchar and char for uuid's.
I don't know if there is a specific reason for not using uuid.

<!-- gh-comment-id:710665624 --> @BlackDex commented on GitHub (Oct 16, 2020): I actually have no idea. I do see we use varchar and char for uuid's. I don't know if there is a specific reason for not using uuid.
Author
Owner

@dani-garcia commented on GitHub (Oct 17, 2020):

I think it's done that way to keep consistency with SQLite, which doesn't have a specific uuid type.

<!-- gh-comment-id:710891306 --> @dani-garcia commented on GitHub (Oct 17, 2020): I think it's done that way to keep consistency with SQLite, which doesn't have a specific uuid type.
Author
Owner

@pounard commented on GitHub (Oct 19, 2020):

For scaling, UUID performance on PostgreSQL is much better than using VARCHAR (CPU and as well memory consumption) - just highlighting this. I regularly do web applications that uses them, there is no consequence in using a VARCHAR on sqlite side and the real UUID type on the pgsql type besides the fact that pgsql will validate them on UPDATE/INSERT operations (with a new error case you must handle in business code, of course). But using a good uuid library, such a validation errors actually never happened to me.

<!-- gh-comment-id:711627581 --> @pounard commented on GitHub (Oct 19, 2020): For scaling, UUID performance on PostgreSQL is much better than using VARCHAR (CPU and as well memory consumption) - just highlighting this. I regularly do web applications that uses them, there is no consequence in using a VARCHAR on sqlite side and the real UUID type on the pgsql type besides the fact that pgsql will validate them on UPDATE/INSERT operations (with a new error case you must handle in business code, of course). But using a good uuid library, such a validation errors actually never happened to me.
Author
Owner

@BlackDex commented on GitHub (Jan 31, 2021):

I'm not sure what to do with this ticket. Do we want to leave it as-is so that we keep a more uniform format in code, or do we want to change this to increase performance and scaling?

I am kinda in favor of keeping it as-is. Also because the main developers/contributors do not use Postgresql them self's as far as i know.
@dani-garcia, what do you think?

<!-- gh-comment-id:770413958 --> @BlackDex commented on GitHub (Jan 31, 2021): I'm not sure what to do with this ticket. Do we want to leave it as-is so that we keep a more uniform format in code, or do we want to change this to _increase performance and scaling_? I am kinda in favor of keeping it as-is. Also because the main developers/contributors do not use Postgresql them self's as far as i know. @dani-garcia, what do you think?
Author
Owner

@pounard commented on GitHub (Feb 1, 2021):

@BlackDex I have no strong feeling, I originally created purely for informational purpose.

<!-- gh-comment-id:770695994 --> @pounard commented on GitHub (Feb 1, 2021): @BlackDex I have no strong feeling, I originally created purely for informational purpose.
Author
Owner

@dani-garcia commented on GitHub (Feb 3, 2021):

If I had to do it all again I'd go with UUIDs too, but seeing as we use uuids everywhere I'd rather keep it as it is now, just to avoid the big migrations we'd have to do to swap them. If the performance ever gets noticeably bad, we can always revisit this decision.

<!-- gh-comment-id:772845113 --> @dani-garcia commented on GitHub (Feb 3, 2021): If I had to do it all again I'd go with UUIDs too, but seeing as we use uuids everywhere I'd rather keep it as it is now, just to avoid the big migrations we'd have to do to swap them. If the performance ever gets noticeably bad, we can always revisit this decision.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#836
No description provided.