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

Store UUIDs in a more efficient manner

Details

    Description

      UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

      The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
      it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end. This ruins the whole idea of prefix compression.

      Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

      So for comparison purposes we'll reorder segments, but keep the byte order inside the segments (i.e. in big endian order):

      MariaDB binary UUIDv1 representation, as returned by the UUID() function:
       
        llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn
       
      Binary sortable representation:
       
         nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll
       
      Sign           Section               Bits   Bytes  Pos   PosBinSortable
      -------------  -------               ----   -----  ---   --------------
      llllllll       time low              32     4        0   12
      mmmm           time mid              16     2        4   10
      Vhhh           version and time hi   16     2        6   8
      vsss           variant and clock seq 16     2        8   6
      nnnnnnnnnnnn   node ID               48     6       10   0
      

      Attachments

        Issue Links

          Activity

            greenman Ian Gilfillan created issue -
            greenman Ian Gilfillan made changes -
            Field Original Value New Value
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Issue Type Task [ 3 ] Bug [ 1 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Assignee Alexander Barkov [ bar ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.7 [ 24805 ]
            serg Sergei Golubchik made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
                Binary UUIDv1 representation:

                  llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

                Binary sortable representation:

                  nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

                Sign Section Bits Bytes Pos PosBinSortable
                ------------- ------- ---- ----- --- --------------
                llllllll time low 32 4 0 12
                mmmm time mid 16 2 4 10
                Vhhh version and time hi 16 2 6 8
                vsss variant and clock seq 16 2 8 6
                nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            bar Alexander Barkov made changes -
            Description UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
                Binary UUIDv1 representation:

                  llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

                Binary sortable representation:

                  nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

                Sign Section Bits Bytes Pos PosBinSortable
                ------------- ------- ---- ----- --- --------------
                llllllll time low 32 4 0 12
                mmmm time mid 16 2 4 10
                Vhhh version and time hi 16 2 6 8
                vsss variant and clock seq 16 2 8 6
                nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            Binary UUIDv1 representation:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            bar Alexander Barkov made changes -
            Description UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            Binary UUIDv1 representation:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            MariaDB binary UUIDv1 representation, as returned by the UUID() function:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            bar Alexander Barkov made changes -
            Description UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            MariaDB binary UUIDv1 representation, as returned by the UUID() function:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end. This ruins the whole idea of prefix compression.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            MariaDB binary UUIDv1 representation, as returned by the UUID() function:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            bar Alexander Barkov made changes -
            Description UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end. This ruins the whole idea of prefix compression.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments:

            {noformat}
            MariaDB binary UUIDv1 representation, as returned by the UUID() function:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            UUIDs are stored in a binary form, but not byte-swapped like in MySQL's uuid_to_bin https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin

            The order provided by UUID_TO_BIN() is not really friendly to index prefix compression:
            it only reorders the timestamp segments, while the clock-seq and the node-ID segments are still at the end. This ruins the whole idea of prefix compression.

            Let's sort UUID in a really index-friendly order, by moving the constant part to the left and the variable part to the right.

            So for comparison purposes we'll reorder segments, but keep the byte order inside the segments (i.e. in big endian order):

            {noformat}
            MariaDB binary UUIDv1 representation, as returned by the UUID() function:

              llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn

            Binary sortable representation:

               nnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll

            Sign Section Bits Bytes Pos PosBinSortable
            ------------- ------- ---- ----- --- --------------
            llllllll time low 32 4 0 12
            mmmm time mid 16 2 4 10
            Vhhh version and time hi 16 2 6 8
            vsss variant and clock seq 16 2 8 6
            nnnnnnnnnnnn node ID 48 6 10 0
            {noformat}
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2021-10-25 10:10:59.0 2021-10-25 10:10:59.4
            bar Alexander Barkov made changes -
            Fix Version/s 10.7.1 [ 26120 ]
            Fix Version/s 10.7 [ 24805 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 125248 ] MariaDB v4 [ 159704 ]
            elenst Elena Stepanova made changes -
            rixafy Rick Strafy made changes -

            People

              bar Alexander Barkov
              greenman Ian Gilfillan
              Votes:
              2 Vote for this issue
              Watchers:
              7 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.