write intensive DB. LSMTree

By | April 24, 2021
Share the joy
  •  
  •  
  •  
  •  
  •  
  •  

scenario, intensive write. Also once written in DB, can be used immediately. Such as

LSM Tree, (Log Structured Merge Tree)
In memory, calld memtable.
In disk called sstable(Sorted String Table)

1. append to WAL first, then append to memtable. In any case system is crashed, can recover from WAL. memtable is sorted. When it reaches the size, flush to disk sstable.
2. When query, 1st find in memtable. If miss, find in disk. The latest record in sstable. The worst case is O(NlogN). N is the number of sstable. Also when query, use bloom filter to improve accuracty.
3. compact. Have a background thread, always compact sstable.

https://www.youtube.com/watch?v=oUNjDHYFES8