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

[Feature]: support uuid v7 as a partition key #7682

Open
punkpeye opened this issue Feb 11, 2025 · 7 comments
Open

[Feature]: support uuid v7 as a partition key #7682

punkpeye opened this issue Feb 11, 2025 · 7 comments
Labels

Comments

@punkpeye
Copy link

What problem does the new feature solve?

Would like to partition hypertable using uuid v7 / ulid.

What does the feature do?

Allows to use UUID-like time-based value as the primary key of a hypertable.

Implementation challenges

No response

@punkpeye punkpeye added the feature-request Feature proposal label Feb 11, 2025
@mkindahl
Copy link
Contributor

UUID version 1, 2, and 6 have timestamps as well, so it is reasonable to support all versions with timestamp as time columns for hypertables.

@punkpeye
Copy link
Author

Is this something that can be expected to happen quickly?

No clue what are the timelines for a typical ask like this with TimescaleDB.

@sergeyprokhorenko
Copy link

UUID version 1, 2, and 6 have timestamps as well, so it is reasonable to support all versions with timestamp as time columns for hypertables.

Older versions of UUID are not suitable as database keys. This is clearly stated in RFC 9562. Only the new version 7 is really popular and worthy of attention and effort. As for version 6, it is a rather crude attempt to fix version 1. I recommend this implementation of version 7: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=78c5e141e9c13

@punkpeye
Copy link
Author

I went with https://github.com/fboulnois/pg_uuidv7

@sergeyprokhorenko
Copy link

I went with https://github.com/fboulnois/pg_uuidv7

It is a temporal solution till PostgreSQL v 18

@punkpeye
Copy link
Author

That's fine. It is one of those extensions that are easy to drop when migrating to v18 since there will be direct substitutes.

so basically, I am understanding timescale right, there is virtually no downside for me to adopt sharding that's based on a timestamp derived from v7 and storing random value in another column?

@sergeyprokhorenko
Copy link

sergeyprokhorenko commented Feb 17, 2025

That's fine. It is one of those extensions that are easy to drop when migrating to v18 since there will be direct substitutes.

Why not just use the new committed implementation right away?

so basically, I am understanding timescale right, there is virtually no downside for me to adopt sharding that's based on a timestamp derived from v7 and storing random value in another column?

Note that the timestamp length varies across implementations. The new implementation adds a 12-bit submillisecond segment. But, as far as I understand, for sharding it is enough to take the left part of the timestamp of any length.

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

3 participants