Get the App
SLTechnology News&Howtos  ›  Database  › 

Does mysql uuid increase in an orderly manner?

Shulou Source: shulou.com Published: 2022-05-31 16:10:45 09月15日 Update

Today, I will talk to you about whether mysql uuid is increasing in an orderly manner. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

A UUID is designed as a number that is globally unique in space and time. Two calls to UUID () are

Expected to generate two different values, even if these calls are performed on two separate computers

That are not connected to each other.

Uuid is the only one in the world, even if two computers with no relationship uuid are different.

However, the document does not say whether it is orderly or not. It is said on the Internet that uuid is disordered. I would like to try a scene:

Scenario explanation:

Build a table with two fields, uuid and time.

Insert a piece of data into this table every second, namely uuid () and now ()

After a period of insertion, if sorting by id is the same as sorting by t_date, then you should be able to prove that uuid is ordered, and if the sorting results are not the same, then it is unordered.

I plugged in two processes here at the same time and ran for two hours.

Simulation process:

Testing on mysql 5.6

Mysql > create table song (id char (36), t_date datetime)

Query OK, 0 rows affected (0.00 sec)

Cat insert.sh

#! / bin/bash

While true; do

Mysql-h20.13.52.100-P3306-uroot-ptest-e "insert into test.song select uuid (), now ();"

Sleep 1

Done

Nohup sh insert.sh &

Nohup sh insert.sh &

Insert the two together.

Run for about two hours, after stopping insert.sh:

Mysql-h20.13.52.100-P3306-uroot-ptest-e "select * from test.song order by tdatedate;" > a.log

Mysql-h20.13.52.100-P3306-uroot-ptest-e "select * from test.song order by id;" > b.log

Diff a.log b.log-y > c.log

[root@10-13-59-213] # vim c.log

Id t_date id t_date

B6af9995-50d2-11e6-9d61-5254005ae15d 2016-07-23 20:41:01 | 0019655a-50d5-11e6-9d61-5254005ae15d 2016-07-23 20:57:24

Cc161c32-50d2-11e6-9d61-5254005ae15d 2016-07-23 20:41:37 | 001968e2-50d5-11e6-9d61-5254005ae15d 2016-07-23 20:57:24

Ccafd852-50d2-11e6-9d61-5254005ae15d 2016-07-23 20:41:38 <

Cd495dc1-50d2-11e6-9d61-5254005ae15d 2016-07-23 20:41:39 <

You can see the difference between a.log and b.log in c.log. Then uuid () is unordered.

After reading the above, do you have any further understanding of whether mysql uuid is increasing in an orderly manner? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Two order content sort different scene hour time result World at the same time Field data document more knowledge Article Industry Table computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology OPPO Reno MariaDB Microsoft Shulou Tech Info