2. About me
DINH HOANG LONG
Group Leader, Bridge Software Engineer
Interested in: PHP, Python, MySQL, Docker, Agile
You can find me at: @dinhhoanglong91
7. MyISAM vs InnoDB
MyISAM
◦ Store rows on disk in the order which they were inserted
◦ Rows are fixed-size
◦ Find row by seeking the required number of bytes
from the beginning
Row number col1(PK) col2
0 99 8
1 12 56
2 3000 62
10. There is no structural difference
between primary key and other index
A primary key is simple a unique, nonnullable index
named PRIMARY
MyISAM
11. MyISAM vs InnoDB
InnoDB - Clustered Index
◦ Rows are stored in the index’s leaf pages
◦ “Clustered”: Rows with adjacent key values are stored close to
each other
14. Secondary indexes access require
two index lookups instead of one
You can have only one clustered index per table, because
you can’t store the row in two places at once
InnoDB
17. Hash index strategy for large column
INSERT INTO users(email, email_crc32, name)
VALUES('long@gmail.com', CRC32('long@gmail.com'), 'Long');
18. Hash index strategy for large column
INSERT INTO users(email, email_crc32, name)
VALUES('long@gmail.com', CRC32('long@gmail.com'), 'Long');
SELECT * FROM users
WHERE email_crc32 = CRC32('long@gmail.com')
AND EMAIL = 'long@gmail.com';
25. References
◦ High Performance MySQL, 3rd Edition
◦ MySQL Indexing
https://viblo.asia/dinhhoanglong91/posts/PDOkqWxAGjx
◦ Sử dụng EXPLAIN để tối ưu câu lệnh MySQL
https://viblo.asia/dinhhoanglong91/posts/BYjv44gmvxpV
◦ MySQL Index Condition Pushdown
https://viblo.asia/dinhhoanglong91/posts/ZjlealAZGqJ