Tests against MySQL index on GUID field
Without guid_field INDEX Tests against SELECT statements. Selects Individual rows using GUID field. Time comparison:
0.0020 - 0.0037 seconds
/
35 - 36 seconds
SELECT * FROM `students123` WHERE guid_field = '90f2c8af-7ead-11eb-9a81-b4b52f79163f'
SELECT * FROM `students123` WHERE guid_field = '90f2c35d-7ead-11eb-9a81-b4b52f79163f'
Selects all rows and orders by the GUID field. Time comparison:
0.0020 seconds
/
35 - 37 seconds
SELECT * FROM `students123` ORDER BY `students123`.`guid_field` DESC
Tests against INSERT statements. Inserts 1.000.000 rows. Time comparison:
34.1974 - 44.1248 seconds
/
18.3200 - 17.4967 seconds
INSERT INTO `students123` (guid_field, student_id, first_name, last_name, points)
SELECT UUID(), student_id, first_name, last_name, points FROM students123 WHERE id < 1000001
Tests against UPDATE statements. Updates 1M rows. Time comparison:
57.2683 - 66.9459 seconds
/
10.2285 - 12.5088 seconds
UPDATE `students123` SET guid_field = UUID() WHERE id > 1000000 AND id < 2000001
Tests against DELETE statements. Deletes 1M rows. Time comparison:
70.3673 - 76.8969 seconds
/
7.1480 - 19.2191 seconds
DELETE FROM `students123` WHERE id > 1000000 AND id < 2000001
To create the table and run the above tests
CREATE TABLE `students123` (
  `id` int(11) NOT NULL,
  `guid_field` varchar(100) NOT NULL,
  `student_id` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `points` int(11) NOT NULL,
  `mail` varchar(255) DEFAULT NULL,
  `mail2` varchar(255) NOT NULL,
  `santa_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
by Valeri Tandilashvili
4 years ago
MySQL
Index
1
Pro tip: use ```triple backticks around text``` to write in code fences