23. BTree
Ordered key-value map
Most common storage type
Quickly find a given key and can be scanned in
order
Works well with ranges
All records between 50 and 100
All records starting with 'R'
25. Other storage types
RTree / Spatial Index
- Identify 'close' values in 2+ dimensions
- Useful for geographic databases
26. Other storage types
RTree / Spatial Index
- Identify 'close' values in 2+ dimensions
- Useful for geographic databases
Hash
- Unordered key/value map
- Faster than BTree, but terrible for ranges
48. Selectivity of a column is
the ratio between the number of
distinct values and the
number of total values
49. Selectivity of a column is
the ratio between the number of
distinct values and the
number of total values
Primary Keys and Unique Columns
Always Have Selectivity of 1
53. Selectivity Tips
Always aim for >15%
Joins on columns with low selectivity are
expensive
Watch out for columns like `status`, `gender`,
and `active`