Storage & indexing — nguyên lý

Cơ chế lưu trữ và đánh chỉ mục nhìn từ nguyên lý, không gắn engine: vì sao cần index, B-tree vs LSM-tree, hash index, đánh đổi đọc/ghi và khi nào KHÔNG nên index.

3 bài · ~60 phútMiễn phí

Nội dung

Danh sách bài học

  1. 01

    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.

    ~20 phút
  2. 02

    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.

    ~20 phút
  3. 03

    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.

    ~20 phút