Details

    Description

      MariaDB provides the UUID method that generates UUID v4, however UUID v4 generates non linear UUIDS that will spread data across different linear partitions based on key or hash.

      The new UUID7 (https://uuid7.com/) will guarantee that continuous records are time sortable and a good collision resistance.

      The main advantage of UUID7 function is that it will allow to MariaDB avoid the limitation of use an unique combined primary key for time series records, where an unique ID and a date is required in order to create key/hash partitions. With UUID7 is possible only use only the key as ID and time reference.

      Right now is possible to generate UUID7 using a poor custom UDF however it may be very slow.

      Attachments

        Issue Links

          Activity

            juanparati Juan Lago created issue -
            serg Sergei Golubchik made changes -
            Field Original Value New Value
            Labels uuid beginner-friendly uuid

            Correction: MariaDB UUID() function generates UUIDv1, not UUIDv4. They are time sortable.

            Anyway, being able to generate UUID's of other versions is a totally valid feature request.

            serg Sergei Golubchik added a comment - Correction: MariaDB UUID() function generates UUIDv1, not UUIDv4. They are time sortable. Anyway, being able to generate UUID's of other versions is a totally valid feature request.
            serg Sergei Golubchik made changes -
            Summary [Feature request] - Implement native UUID7 function Implement native UUID7 function
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            danblack Daniel Black added a comment - - edited

            In the mean time, a fast uuidv7:

            From https://github.com/pluots/udf-suite/releases

            doc: https://github.com/pluots/udf-suite/blob/main/udf-uuid/README.md

            Untar from the github release with the .so files put into /usr/lib/mysql/plugin

            MariaDB [test]> CREATE FUNCTION uuid_generate_v7 RETURNS string SONAME 'libudf_uuid.so';
            Query OK, 0 rows affected (0.000 sec)
             
             
            MariaDB [test]> SELECT BENCHMARK(1000000,uuid_generate_v7());
            +---------------------------------------+
            | BENCHMARK(1000000,uuid_generate_v7()) |
            +---------------------------------------+
            |                                     0 |
            +---------------------------------------+
            1 row in set (0.063 sec)
            

            Unlike the SQL version you had which generates invalid uuids:

            MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7());
            ERROR 1292 (22007): Incorrect uuid value: '06541949-30-7602-4E1D-DD59E218E01A'
            MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7());
            ERROR 1292 (22007): Incorrect uuid value: '0654194A-90-738F-4364-563AF35DC398'
            MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7());
            ERROR 1292 (22007): Incorrect uuid value: '0654194A-30-75A3-48A3-89854C46C137'
            MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7());
            ERROR 1292 (22007): Incorrect uuid value: '0654194A-70-7E23-49E4-E49A5AE9C3FE'
            

            danblack Daniel Black added a comment - - edited In the mean time, a fast uuidv7: From https://github.com/pluots/udf-suite/releases doc: https://github.com/pluots/udf-suite/blob/main/udf-uuid/README.md Untar from the github release with the .so files put into /usr/lib/mysql/plugin MariaDB [test]> CREATE FUNCTION uuid_generate_v7 RETURNS string SONAME 'libudf_uuid.so' ; Query OK, 0 rows affected (0.000 sec)     MariaDB [test]> SELECT BENCHMARK(1000000,uuid_generate_v7()); + ---------------------------------------+ | BENCHMARK(1000000,uuid_generate_v7()) | + ---------------------------------------+ | 0 | + ---------------------------------------+ 1 row in set (0.063 sec) Unlike the SQL version you had which generates invalid uuids: MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7()); ERROR 1292 (22007): Incorrect uuid value: '06541949-30-7602-4E1D-DD59E218E01A' MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7()); ERROR 1292 (22007): Incorrect uuid value: '0654194A-90-738F-4364-563AF35DC398' MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7()); ERROR 1292 (22007): Incorrect uuid value: '0654194A-30-75A3-48A3-89854C46C137' MariaDB [test]> SELECT BENCHMARK(1000000,uuidv7()); ERROR 1292 (22007): Incorrect uuid value: '0654194A-70-7E23-49E4-E49A5AE9C3FE'
            juanparati Juan Lago added a comment -

            @Daniel Black: Thank you for provide me a plugin that can generate UUIDv7. Unfortunately some the server that I am using are hosted in cloud providers like AWS and they don't allow to install custom plugins.

            I will fix the UDF so it will generate correctly UUID7.

            juanparati Juan Lago added a comment - @Daniel Black: Thank you for provide me a plugin that can generate UUIDv7. Unfortunately some the server that I am using are hosted in cloud providers like AWS and they don't allow to install custom plugins. I will fix the UDF so it will generate correctly UUID7.
            danblack Daniel Black added a comment - - edited

            Sorry to hear that. Welcome a share of the corrected SQL too.

            If anyone feels comfortable implementing it, the two item_uuidfunc* files in https://github.com/MariaDB/server/tree/11.3/plugin/type_uuid contain the current UUIDv1 implementation. Adding 1 class and an implementation is all that is required.

            And the my_uuid function is a useful reference.

            danblack Daniel Black added a comment - - edited Sorry to hear that. Welcome a share of the corrected SQL too. If anyone feels comfortable implementing it, the two item_uuidfunc* files in https://github.com/MariaDB/server/tree/11.3/plugin/type_uuid contain the current UUIDv1 implementation. Adding 1 class and an implementation is all that is required. And the my_uuid function is a useful reference.
            juanparati Juan Lago added a comment -

            I fixed the code.

            I also implemented a procedure that test collisions.

            juanparati Juan Lago added a comment - I fixed the code. I also implemented a procedure that test collisions.
            jdeepd Jaydeep Das added a comment - - edited

            juanparati, danblack, So, is the issue fixed or still open to work on?

            jdeepd Jaydeep Das added a comment - - edited juanparati , danblack , So, is the issue fixed or still open to work on?
            juanparati Juan Lago added a comment -

            @Jaydeep Das: I am not MariaDB developer. I just fixed a poor function that can we use as a workaround: https://gist.github.com/juanparati/0ded9c04d4cd43e5aae8f5a438a8b18b

            juanparati Juan Lago added a comment - @Jaydeep Das: I am not MariaDB developer. I just fixed a poor function that can we use as a workaround: https://gist.github.com/juanparati/0ded9c04d4cd43e5aae8f5a438a8b18b
            Stefano Petrilli Stefano Petrilli made changes -
            Stefano Petrilli Stefano Petrilli made changes -
            danblack Daniel Black made changes -
            Issue Type Task [ 3 ] New Feature [ 2 ]
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.6 [ 24028 ]
            serg Sergei Golubchik made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            bar Alexander Barkov made changes -
            Status In Review [ 10002 ] In Testing [ 10301 ]
            bar Alexander Barkov made changes -
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            bar Alexander Barkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]

            Hello serg Can you please review the pull request from StefanoPetrilli:

            https://github.com/MariaDB/server/pull/3093
            ?

            The low level UUDIv7 generation code is especially interesting.
            Couldn't we reuse some of UUIDv1 code?

            Thanks.

            bar Alexander Barkov added a comment - Hello serg Can you please review the pull request from StefanoPetrilli: https://github.com/MariaDB/server/pull/3093 ? The low level UUDIv7 generation code is especially interesting. Couldn't we reuse some of UUIDv1 code? Thanks.
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.6 [ 29515 ]
            Fix Version/s 10.6 [ 24028 ]
            danblack Daniel Black added a comment -

            note - ensure MDEV-32583 fix is applied here too.

            danblack Daniel Black added a comment - note - ensure MDEV-32583 fix is applied here too.
            danblack Daniel Black made changes -
            serg Sergei Golubchik made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.7 [ 29815 ]
            Fix Version/s 11.6 [ 29515 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Status Stalled [ 10000 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            serg Sergei Golubchik added a comment - - edited

            bb-11.7-MDEV-33710-uuid is ready for testing. It has both UUIDv4 and UUIDv7

            serg Sergei Golubchik added a comment - - edited bb-11.7- MDEV-33710 -uuid is ready for testing. It has both UUIDv4 and UUIDv7
            serg Sergei Golubchik made changes -
            Status In Review [ 10002 ] In Testing [ 10301 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alice Sherepa [ alice ]

            let's change the name to match what percona has

            serg Sergei Golubchik added a comment - let's change the name to match what percona has
            serg Sergei Golubchik made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Labels beginner-friendly uuid Preview_11.7 beginner-friendly uuid
            alice Alice Sherepa made changes -
            alice Alice Sherepa made changes -
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            alice Alice Sherepa made changes -
            Assignee Alice Sherepa [ alice ] Alexander Barkov [ bar ]
            serg Sergei Golubchik made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Component/s Server [ 13907 ]
            Fix Version/s 11.7.1 [ 29913 ]
            Fix Version/s 11.7 [ 29815 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]

            People

              serg Sergei Golubchik
              juanparati Juan Lago
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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