Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
None
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
- causes
-
MDEV-29959 UUID Sorting
-
- Closed
-
- is caused by
-
MDEV-4958 Adding datatype UUID
-
- Closed
-
- relates to
-
MDEV-20477 Merge binlog extended metadata support from the upstream
-
- Closed
-
-
MDEV-27588 MyISAM/Aria descending index compression is not as efficient as ascending
-
- Closed
-
- links to
Activity
Issue Type | Task [ 3 ] | Bug [ 1 ] |
Assignee | Alexander Barkov [ bar ] |
Fix Version/s | 10.7 [ 24805 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Remote Link | This issue links to "The uniqueidentifier data type in SQL server (Web Link)" [ 32200 ] |
Remote Link | This issue links to "SQL Server GUID sort algorithm. Why? (Web Link)" [ 32201 ] |
Remote Link | This issue links to "How are GUIDs compared in SQL Server 2005? (Web Link)" [ 32202 ] |
Link |
This issue relates to |
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} |
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} |
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} |
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} |
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} |
Status | Open [ 1 ] | In Progress [ 3 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
issue.field.resolutiondate | 2021-10-25 10:10:59.0 | 2021-10-25 10:10:59.4 |
Fix Version/s | 10.7.1 [ 26120 ] | |
Fix Version/s | 10.7 [ 24805 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 125248 ] | MariaDB v4 [ 159704 ] |
Link |
This issue relates to |
Link |
This issue causes |