GUID Database Performance & Indexing Guide
Complete guide to GUID database performance, B-tree index behavior, fragmentation, storage optimization and database-specific considerations.
Generate UUIDs in MariaDB with UUID() for UUID v1, and use UUID_v4() or UUID_v7() on MariaDB 11.7 and newer when you need random or time-ordered values.
UUID_v7() for append-heavy tables and UUID_v4() when you need random identifiers without time ordering.SELECT UUID() AS uuid_v1_value;MariaDB documents UUID() as a UUID v1 generator.
SELECT UUID_v4() AS uuid_v4_value,
UUID_v7() AS uuid_v7_value;UUID_v4() and UUID_v7() are available from MariaDB 11.7.
CREATE TABLE events (
id BINARY(16) PRIMARY KEY,
event_name VARCHAR(100) NOT NULL
);
INSERT INTO events (id, event_name)
VALUES (UUID_TO_BIN(UUID_v7()), 'user.created');
SELECT BIN_TO_UUID(id) AS id, event_name
FROM events;UUID() generates UUID v1 values.UUID_v4() and UUID_v7() are available from MariaDB 11.7.UUID_TO_BIN() and BIN_TO_UUID() help with compact binary storage.BINARY(16) if you care about index size and storage overhead.UUID_v7().UUID() for UUID v1 generation, but MariaDB also adds native UUID_v4() and UUID_v7() support from version 11.7.These articles expand on related concepts, formats and practical considerations.