Nội dung
Danh sách bài học
- 01~20 phút
Tại sao cần index — full scan 800ms vs index scan 0.2ms
Heap = unsorted data. Index = sorted lookup table. 4000x speedup. 3 scan strategy: full scan / index scan / index-only scan. When index NOT help.
- 02~20 phút
B-tree vs LSM-tree — hai triết lý lưu trữ index
B-tree update tại chỗ, tối ưu đọc. LSM-tree ghi nối tiếp, tối ưu ghi. Đánh đổi write vs read amplification, sequential vs random I/O — agnostic theo tinh thần DDIA.
- 03~20 phút
Hash index và bức tranh các loại index
Hash index tra equality O(1) nhưng mù range. B-tree cho range, hash cho equality, cùng inverted/spatial/bitmap — chọn loại index theo hình dạng truy vấn.