2021 年 07 月 === ### partition & sharding partition 同機器 sharding 不同機器 ### 不同的 partitioning 方式 range 例如 age 1-10, 11-20 list 例如透過 by 國家切 composite 分散讓 load 平均 round-robin ## 水平 vs 垂直 水平: by row 切 垂直: by column 切 ## 其他補充 consistency hashing:讓每個節點內容平均 [(參考)](https://medium.com/@chyeh/consistent-hashing-algorithm-%E6%87%89%E7%94%A8%E6%83%85%E5%A2%83-%E5%8E%9F%E7%90%86%E8%88%87%E5%AF%A6%E4%BD%9C%E7%AF%84%E4%BE%8B-41fd16ad334a) index 不會跨表,跨 partition 的查詢成本會很高 大部分 noSQL 通常內建 sharding mongo DB 不用 B+ tree 而用 B tree 比較方便做 sharding ![](https://i.imgur.com/2feipho.png) ProxySQL hash partitioning OLAP & OLTP OLTP: 事務類型,重點在 transactional、ACID OLAP: 目標是分析,重點在 aggregating, batch processing 等,例如報表 paxos algorithm 不是一致性演算法,而是共識演算法,例如多數決的方式 event sourcing CQRS command query request s phanthom read