-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support microsecond resolution #12
Comments
As I outline in my comments on the RFC, I don't really like the alternate pseudorandom constructions. I'd also like to keep this extension as simple as possible so that there is only one way to build v7 UUIDs. As a result it is unlikely I will implement this. |
Understood, thanks. I also hadn't noticed that the v7 draft has advanced since I started working with it, so for me I'm glad to see an optional additional time precision provision has been added to the proposal. |
I appreciate you said you were unlikely to add the optional extra time precision support into this extension, but I thought I'd have a go at trying to add this, and I thought the change could be quite focused with the addition of a default/optional argument to the I started playing around and was able to get something started along these lines, just for testing purposes, but my Postgres extension experience is limited and thought you might have more thoughts on the matter. |
It might be easier to initially extract microseconds and then split it into millis and micros, but otherwise your approach seems reasonable to me. |
I've flushed out the fractional millisecond support now, including updating the README. I also added some basic tests (run via If you ever change your mind and would be interested in a PR, I'm happy to create one. |
I am glad you were able to find a solution to your issue. With the addition of |
Thank you for writing this handy extension! I wondered if you would consider adding a function to create a v7 UUID variant with microsecond precision, by making use of the high 10 bits of bytes 6 & 7 for a 0-999 microseconds value instead of random bits. The reason for this is because I found the millisecond-level precision in a v7 UUID inadequate for an application I worked on, and using microseconds was a good compromise between time precision and randomness.
The UUID layout looks like this:
I thought this could be an additional function like
uuid_generate_v7_micro()
so it did not impact the existinguuid_generate_v7()
function. I have been using a SQL function for this, but a C function would be much faster!The text was updated successfully, but these errors were encountered: