Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33710

Implement Timestamp Extraction for UUIDv1 and UUIDv7

Details

    Description

      The new UUIDv7 (https://uuid7.com/) is generated using the current timestamp and allows for easy retrieval of its generation time.

      It would be useful to have a function ExtractTimestampFromUUIDv7(uuid) that takes as an input a UUIDv7 and returns the timestamp when it has been generated.

      Also, it could do it for UUIDv1 that contains a temporal part too

      Attachments

        Issue Links

          Activity

            HazemRawi Hazem Alrawi added a comment -

            Can I work on this feature?

            HazemRawi Hazem Alrawi added a comment - Can I work on this feature?

            Yes, of course, you can.
            Although, at the moment it does not look very likely that we will merge it — this MDEV is an idea of a feature, but it'd be good to know more about actual use cases, real world users asking for it for their real world applications, you know, some practical justification for adding it. As of now it doesn't look like a feature that users will actually use.

            But if you just want something to practice — this is a good one, indeed.

            serg Sergei Golubchik added a comment - Yes, of course, you can. Although, at the moment it does not look very likely that we will merge it — this MDEV is an idea of a feature, but it'd be good to know more about actual use cases, real world users asking for it for their real world applications, you know, some practical justification for adding it. As of now it doesn't look like a feature that users will actually use. But if you just want something to practice — this is a good one, indeed.

            Can you please make sure that this function is usable for a generated column?

            f_razzoli Federico Razzoli added a comment - Can you please make sure that this function is usable for a generated column?

            f_razzoli, could you please describe your use case? How do you plan to use this function?

            serg Sergei Golubchik added a comment - f_razzoli , could you please describe your use case? How do you plan to use this function?

            I already recommend customers to use the UUID type as a primary key. I noticed that some customers add a second UUID column that changes every time a row is updated. I don't know the reason.

            I'll recommend to use UUID7 when it's in an LTS branch, because it doesn't require MariaDB to shuffle the bits under the hood.

            Also, typical tables have timestamp columns like inserted_at and updated_at. Seems to me a good idea to "link" them to the UUID's, to ensure that if col_uuid changes col_timestamp will change and vice versa. It can also be useful to select recently changed rows from a table that doesn't have timestamps.

            f_razzoli Federico Razzoli added a comment - I already recommend customers to use the UUID type as a primary key. I noticed that some customers add a second UUID column that changes every time a row is updated. I don't know the reason. I'll recommend to use UUID7 when it's in an LTS branch, because it doesn't require MariaDB to shuffle the bits under the hood. Also, typical tables have timestamp columns like inserted_at and updated_at. Seems to me a good idea to "link" them to the UUID's, to ensure that if col_uuid changes col_timestamp will change and vice versa. It can also be useful to select recently changed rows from a table that doesn't have timestamps.

            "doesn't require MariaDB to shuffle the bits under the hood" doesn't sound like an argument to me, why would anyone care what MariaDB is doing under the hood? I expected people to use UUID7 mainly for compatibility with other applications. UUIDv1 has better temporal resolution, one can generate them with a higher rate.

            Anyway, okay, this sounds like a possible use case. Additionally, I think, this new function can also extract time part from UUIDv1, that fits into your use case too.

            serg Sergei Golubchik added a comment - "doesn't require MariaDB to shuffle the bits under the hood" doesn't sound like an argument to me, why would anyone care what MariaDB is doing under the hood? I expected people to use UUID7 mainly for compatibility with other applications. UUIDv1 has better temporal resolution, one can generate them with a higher rate. Anyway, okay, this sounds like a possible use case. Additionally, I think, this new function can also extract time part from UUIDv1, that fits into your use case too.
            HazemRawi Hazem Alrawi added a comment -

            Okay, I'll come back to this later. For now, I'll focus on major priority issues.

            HazemRawi Hazem Alrawi added a comment - Okay, I'll come back to this later. For now, I'll focus on major priority issues.

            People

              Unassigned Unassigned
              Stefano Petrilli Stefano Petrilli
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.