# 目錄

> DDIA 第二版完整目錄：十四章，涵蓋資料系統基礎、分散式資料與派生資料。

---

LLMS 索引： [llms.txt](/tw/llms.txt)

---

![](/title.jpg)

這份目錄與左側章節樹、頁末順序導航共享同一閱讀順序；章內標題直接來自各頁的穩定錨點。選擇任意條目即可進入對應章節或小節。

- [目錄](/tw/toc/)
  - [插圖目錄](/tw/toc/#list-of-figures)
  - [表格目錄](/tw/toc/#list-of-tables)
  - [示例目錄](/tw/toc/#list-of-examples)
- [序言](/tw/preface/)
  - [本書的目標讀者](/tw/preface/#本書的目標讀者)
  - [本書涉及的領域](/tw/preface/#本書涉及的領域)
  - [本書綱要](/tw/preface/#本書綱要)
  - [參考文獻與延伸閱讀](/tw/preface/#參考文獻與延伸閱讀)
  - [O‘Reilly Safari](/tw/preface/#oreilly-safari)
  - [聯絡我們](/tw/preface/#聯絡我們)
  - [致謝](/tw/preface/#致謝)
- [I 資料系統基礎](/tw/part-i/)
  - [1. 資料系統架構中的權衡](/tw/part-i/#1-資料系統架構中的權衡)
  - [2. 定義非功能性需求](/tw/part-i/#2-定義非功能性需求)
  - [3. 資料模型與查詢語言](/tw/part-i/#3-資料模型與查詢語言)
  - [4. 儲存與檢索](/tw/part-i/#4-儲存與檢索)
  - [5. 編碼與演化](/tw/part-i/#5-編碼與演化)
- [1 資料系統架構中的權衡](/tw/ch1/)
  - [分析型與事務型系統](/tw/ch1/#sec_introduction_analytics)
    - [事務處理與分析的特徵](/tw/ch1/#sec_introduction_oltp)
    - [資料倉儲](/tw/ch1/#sec_introduction_dwh)
      - [從資料倉儲到資料湖](/tw/ch1/#from-data-warehouse-to-data-lake)
      - [超越資料湖](/tw/ch1/#beyond-the-data-lake)
    - [權威記錄系統與衍生資料](/tw/ch1/#sec_introduction_derived)
  - [雲服務與自託管](/tw/ch1/#sec_introduction_cloud)
    - [雲服務的利弊](/tw/ch1/#sec_introduction_cloud_tradeoffs)
    - [雲原生系統架構](/tw/ch1/#sec_introduction_cloud_native)
      - [雲服務的分層](/tw/ch1/#layering-of-cloud-services)
      - [儲存與計算的分離](/tw/ch1/#sec_introduction_storage_compute)
    - [雲時代的運維](/tw/ch1/#sec_introduction_operations)
  - [分散式與單節點系統](/tw/ch1/#sec_introduction_distributed)
    - [分散式系統的問題](/tw/ch1/#sec_introduction_dist_sys_problems)
    - [微服務與無伺服器](/tw/ch1/#sec_introduction_microservices)
    - [雲端計算與超級計算](/tw/ch1/#id17)
  - [資料系統、法律與社會](/tw/ch1/#sec_introduction_compliance)
  - [總結](/tw/ch1/#summary)
    - [參考文獻](/tw/ch1/#參考文獻)
- [2 定義非功能性需求](/tw/ch2/)
  - [案例研究：社交網路首頁時間線](/tw/ch2/#sec_introduction_twitter)
    - [表示使用者、帖子與關注關係](/tw/ch2/#id20)
    - [時間線的物化與更新](/tw/ch2/#sec_introduction_materializing)
  - [描述效能](/tw/ch2/#sec_introduction_percentiles)
    - [延遲與響應時間](/tw/ch2/#id23)
    - [平均值、中位數與分位數](/tw/ch2/#id24)
    - [響應時間指標的應用](/tw/ch2/#sec_introduction_slo_sla)
  - [可靠性與容錯](/tw/ch2/#sec_introduction_reliability)
    - [容錯](/tw/ch2/#id27)
    - [硬體與軟體故障](/tw/ch2/#sec_introduction_hardware_faults)
      - [透過冗餘容忍硬體故障](/tw/ch2/#tolerating-hardware-faults-through-redundancy)
      - [軟體故障](/tw/ch2/#software-faults)
    - [人類與可靠性](/tw/ch2/#id31)
  - [可伸縮性](/tw/ch2/#sec_introduction_scalability)
    - [描述負載](/tw/ch2/#id33)
    - [共享記憶體、共享磁碟與無共享架構](/tw/ch2/#sec_introduction_shared_nothing)
    - [可伸縮性原則](/tw/ch2/#id35)
  - [可維護性](/tw/ch2/#sec_introduction_maintainability)
    - [可運維性：讓運維更輕鬆](/tw/ch2/#id37)
    - [簡單性：管理複雜度](/tw/ch2/#id38)
    - [可演化性：讓變化更容易](/tw/ch2/#sec_introduction_evolvability)
  - [總結](/tw/ch2/#summary)
    - [參考文獻](/tw/ch2/#參考文獻)
- [3 資料模型與查詢語言](/tw/ch3/)
  - [關係模型與文件模型](/tw/ch3/#sec_datamodels_history)
    - [物件關係不匹配](/tw/ch3/#sec_datamodels_document)
      - [物件關係對映（ORM）](/tw/ch3/#object-relational-mapping-orm)
      - [用於一對多關係的文件資料模型](/tw/ch3/#the-document-data-model-for-one-to-many-relationships)
    - [正規化、反正規化與連線](/tw/ch3/#sec_datamodels_normalization)
      - [正規化的權衡](/tw/ch3/#trade-offs-of-normalization)
      - [社交網路案例研究中的反正規化](/tw/ch3/#denormalization-in-the-social-networking-case-study)
    - [多對一與多對多關係](/tw/ch3/#sec_datamodels_many_to_many)
    - [星型與雪花型：分析模式](/tw/ch3/#sec_datamodels_analytics)
    - [何時使用哪種模型](/tw/ch3/#sec_datamodels_document_summary)
      - [文件模型中的模式靈活性](/tw/ch3/#sec_datamodels_schema_flexibility)
      - [讀寫的資料區域性](/tw/ch3/#sec_datamodels_document_locality)
      - [文件的查詢語言](/tw/ch3/#query-languages-for-documents)
      - [文件和關聯式資料庫的融合](/tw/ch3/#convergence-of-document-and-relational-databases)
  - [圖資料模型](/tw/ch3/#sec_datamodels_graph)
    - [屬性圖](/tw/ch3/#id56)
    - [Cypher 查詢語言](/tw/ch3/#id57)
    - [SQL 中的圖查詢](/tw/ch3/#id58)
    - [三元組儲存與 SPARQL](/tw/ch3/#id59)
      - [RDF 資料模型](/tw/ch3/#the-rdf-data-model)
      - [SPARQL 查詢語言](/tw/ch3/#the-sparql-query-language)
    - [Datalog：遞迴關係查詢](/tw/ch3/#id62)
    - [GraphQL](/tw/ch3/#id63)
  - [事件溯源與 CQRS](/tw/ch3/#sec_datamodels_events)
  - [資料框、矩陣與陣列](/tw/ch3/#sec_datamodels_dataframes)
  - [總結](/tw/ch3/#summary)
    - [參考文獻](/tw/ch3/#參考文獻)
- [4 儲存與檢索](/tw/ch4/)
  - [OLTP 系統的儲存與索引](/tw/ch4/#sec_storage_oltp)
    - [日誌結構儲存](/tw/ch4/#sec_storage_log_structured)
      - [SSTable 檔案格式](/tw/ch4/#the-sstable-file-format)
      - [構建和合並 SSTable](/tw/ch4/#constructing-and-merging-sstables)
      - [布隆過濾器](/tw/ch4/#bloom-filters)
      - [壓實策略](/tw/ch4/#sec_storage_lsm_compaction)
    - [B 樹](/tw/ch4/#sec_storage_b_trees)
      - [使 B 樹可靠](/tw/ch4/#sec_storage_btree_wal)
      - [B 樹變體](/tw/ch4/#b-tree-variants)
    - [比較 B 樹與 LSM 樹](/tw/ch4/#sec_storage_btree_lsm_comparison)
      - [讀取效能](/tw/ch4/#read-performance)
      - [順序與隨機寫入](/tw/ch4/#sidebar_sequential)
      - [寫放大](/tw/ch4/#write-amplification)
      - [磁碟空間使用](/tw/ch4/#disk-space-usage)
    - [多列索引與二級索引](/tw/ch4/#sec_storage_index_multicolumn)
      - [在索引中儲存值](/tw/ch4/#sec_storage_index_heap)
    - [全記憶體儲存](/tw/ch4/#sec_storage_inmemory)
  - [分析型資料儲存](/tw/ch4/#sec_storage_analytics)
    - [雲資料倉儲](/tw/ch4/#sec_cloud_data_warehouses)
    - [列式儲存](/tw/ch4/#sec_storage_column)
      - [列壓縮](/tw/ch4/#sec_storage_column_compression)
      - [列儲存中的排序順序](/tw/ch4/#sort-order-in-column-storage)
      - [寫入列式儲存](/tw/ch4/#writing-to-column-oriented-storage)
    - [查詢執行：編譯與向量化](/tw/ch4/#sec_storage_vectorized)
    - [物化檢視與多維資料集](/tw/ch4/#sec_storage_materialized_views)
  - [多維索引與全文索引](/tw/ch4/#sec_storage_multidimensional)
    - [全文檢索](/tw/ch4/#sec_storage_full_text)
    - [向量嵌入](/tw/ch4/#id92)
  - [總結](/tw/ch4/#summary)
    - [參考文獻](/tw/ch4/#參考文獻)
- [5 編碼與演化](/tw/ch5/)
  - [編碼資料的格式](/tw/ch5/#sec_encoding_formats)
    - [特定語言的格式](/tw/ch5/#id96)
    - [JSON、XML 及其二進位制變體](/tw/ch5/#sec_encoding_json)
      - [JSON 模式](/tw/ch5/#json-schema)
      - [二進位制編碼](/tw/ch5/#binary-encoding)
    - [Protocol Buffers](/tw/ch5/#sec_encoding_protobuf)
      - [欄位標籤與模式演化](/tw/ch5/#field-tags-and-schema-evolution)
    - [Avro](/tw/ch5/#sec_encoding_avro)
      - [寫入者模式與讀取者模式](/tw/ch5/#the-writers-schema-and-the-readers-schema)
      - [模式演化規則](/tw/ch5/#schema-evolution-rules)
      - [但什麼是寫入者模式？](/tw/ch5/#but-what-is-the-writers-schema)
      - [動態生成的模式](/tw/ch5/#dynamically-generated-schemas)
    - [模式的優點](/tw/ch5/#sec_encoding_schemas)
  - [資料流的模式](/tw/ch5/#sec_encoding_dataflow)
    - [流經資料庫的資料流](/tw/ch5/#sec_encoding_dataflow_db)
      - [不同時間寫入的不同值](/tw/ch5/#different-values-written-at-different-times)
      - [歸檔儲存](/tw/ch5/#archival-storage)
    - [流經服務的資料流：REST 與 RPC](/tw/ch5/#sec_encoding_dataflow_rpc)
      - [Web 服務](/tw/ch5/#sec_web_services)
      - [遠端過程呼叫（RPC）的問題](/tw/ch5/#sec_problems_with_rpc)
      - [負載均衡器、服務發現和服務網格](/tw/ch5/#sec_encoding_service_discovery)
      - [RPC 的資料編碼與演化](/tw/ch5/#data-encoding-and-evolution-for-rpc)
    - [持久化執行與工作流](/tw/ch5/#sec_encoding_dataflow_workflows)
      - [持久化執行](/tw/ch5/#durable-execution)
    - [事件驅動的架構](/tw/ch5/#sec_encoding_dataflow_msg)
      - [訊息代理](/tw/ch5/#message-brokers)
      - [分散式 actor 框架](/tw/ch5/#distributed-actor-frameworks)
  - [總結](/tw/ch5/#summary)
    - [參考文獻](/tw/ch5/#參考文獻)
- [II 分散式資料](/tw/part-ii/)
  - [伸縮至更高的負載](/tw/part-ii/#伸縮至更高的負載)
    - [無共享架構](/tw/part-ii/#無共享架構)
    - [複製 vs 分割槽](/tw/part-ii/#複製-vs-分割槽)
  - [6. 複製](/tw/part-ii/#6-複製)
  - [7. 分片](/tw/part-ii/#7-分片)
  - [8. 事務](/tw/part-ii/#8-事務)
  - [9. 分散式系統的麻煩](/tw/part-ii/#9-分散式系統的麻煩)
  - [10. 一致性與共識](/tw/part-ii/#10-一致性與共識)
    - [參考](/tw/part-ii/#參考)
- [6 複製](/tw/ch6/)
  - [單主複製](/tw/ch6/#sec_replication_leader)
    - [同步複製與非同步複製](/tw/ch6/#sec_replication_sync_async)
    - [設定新的副本](/tw/ch6/#sec_replication_new_replica)
    - [處理節點故障](/tw/ch6/#sec_replication_failover)
      - [追隨者失效：追趕恢復](/tw/ch6/#follower-failure-catch-up-recovery)
      - [領導者失效：故障切換](/tw/ch6/#leader-failure-failover)
    - [複製日誌的實現](/tw/ch6/#sec_replication_implementation)
      - [基於語句的複製](/tw/ch6/#statement-based-replication)
      - [預寫日誌（WAL）傳輸](/tw/ch6/#write-ahead-log-wal-shipping)
      - [邏輯（基於行）日誌複製](/tw/ch6/#logical-row-based-log-replication)
  - [複製延遲的問題](/tw/ch6/#sec_replication_lag)
    - [讀己之寫](/tw/ch6/#sec_replication_ryw)
    - [單調讀](/tw/ch6/#sec_replication_monotonic_reads)
    - [一致字首讀](/tw/ch6/#sec_replication_consistent_prefix)
    - [複製延遲的解決方案](/tw/ch6/#id131)
  - [多主複製](/tw/ch6/#sec_replication_multi_leader)
    - [跨地域執行](/tw/ch6/#sec_replication_multi_dc)
      - [多主複製拓撲](/tw/ch6/#sec_replication_topologies)
      - [不同拓撲的問題](/tw/ch6/#problems-with-different-topologies)
    - [同步引擎與本地優先軟體](/tw/ch6/#sec_replication_offline_clients)
      - [實時協作、離線優先和本地優先應用](/tw/ch6/#real-time-collaboration-offline-first-and-local-first-apps)
      - [同步引擎的利弊](/tw/ch6/#pros-and-cons-of-sync-engines)
    - [處理寫入衝突](/tw/ch6/#sec_replication_write_conflicts)
      - [衝突避免](/tw/ch6/#conflict-avoidance)
      - [最後寫入者勝（丟棄併發寫入）](/tw/ch6/#sec_replication_lww)
      - [手動衝突解決](/tw/ch6/#manual-conflict-resolution)
      - [自動衝突解決](/tw/ch6/#automatic-conflict-resolution)
    - [CRDT 與操作變換](/tw/ch6/#sec_replication_crdts)
      - [什麼是衝突？](/tw/ch6/#what-is-a-conflict)
  - [無主複製](/tw/ch6/#sec_replication_leaderless)
    - [當節點故障時寫入資料庫](/tw/ch6/#id287)
      - [追趕錯過的寫入](/tw/ch6/#sec_replication_read_repair)
      - [讀寫仲裁](/tw/ch6/#sec_replication_quorum_condition)
    - [仲裁一致性的侷限](/tw/ch6/#sec_replication_quorum_limitations)
      - [監控陳舊性](/tw/ch6/#monitoring-staleness)
    - [單主與無主複製的效能](/tw/ch6/#sec_replication_leaderless_perf)
      - [多地區操作](/tw/ch6/#multi-region-operation)
    - [檢測併發寫入](/tw/ch6/#sec_replication_concurrent)
      - [“先發生”關係與併發](/tw/ch6/#sec_replication_happens_before)
      - [捕獲先發生關係](/tw/ch6/#capturing-the-happens-before-relationship)
      - [版本向量](/tw/ch6/#version-vectors)
  - [總結](/tw/ch6/#summary)
    - [參考文獻](/tw/ch6/#參考文獻)
- [7 分片](/tw/ch7/)
  - [分片的利與弊](/tw/ch7/#sec_sharding_reasons)
    - [面向多租戶的分片](/tw/ch7/#sec_sharding_multitenancy)
  - [鍵值資料的分片](/tw/ch7/#sec_sharding_key_value)
    - [按鍵的範圍分片](/tw/ch7/#sec_sharding_key_range)
      - [再平衡鍵範圍分片資料](/tw/ch7/#rebalancing-key-range-sharded-data)
    - [按鍵的雜湊分片](/tw/ch7/#sec_sharding_hash)
      - [雜湊取模節點數](/tw/ch7/#hash-modulo-number-of-nodes)
      - [固定數量的分片](/tw/ch7/#fixed-number-of-shards)
      - [按雜湊範圍分片](/tw/ch7/#sharding-by-hash-range)
      - [一致性雜湊](/tw/ch7/#sec_sharding_consistent_hashing)
    - [傾斜的工作負載與緩解熱點](/tw/ch7/#sec_sharding_skew)
    - [運維：自動/手動再平衡](/tw/ch7/#sec_sharding_operations)
  - [請求路由](/tw/ch7/#sec_sharding_routing)
  - [分片與二級索引](/tw/ch7/#sec_sharding_secondary_indexes)
    - [本地二級索引](/tw/ch7/#id166)
    - [全域性二級索引](/tw/ch7/#id167)
  - [總結](/tw/ch7/#summary)
    - [參考文獻](/tw/ch7/#參考文獻)
- [8 事務](/tw/ch8/)
  - [事務到底是什麼？](/tw/ch8/#sec_transactions_overview)
    - [ACID 的含義](/tw/ch8/#sec_transactions_acid)
      - [原子性](/tw/ch8/#sec_transactions_acid_atomicity)
      - [一致性](/tw/ch8/#sec_transactions_acid_consistency)
      - [隔離性](/tw/ch8/#sec_transactions_acid_isolation)
      - [永續性](/tw/ch8/#durability)
    - [單物件與多物件操作](/tw/ch8/#sec_transactions_multi_object)
      - [單物件寫入](/tw/ch8/#sec_transactions_single_object)
      - [多物件事務的需求](/tw/ch8/#sec_transactions_need)
      - [處理錯誤和中止](/tw/ch8/#handling-errors-and-aborts)
  - [弱隔離級別](/tw/ch8/#sec_transactions_isolation_levels)
    - [讀已提交](/tw/ch8/#sec_transactions_read_committed)
      - [沒有髒讀](/tw/ch8/#no-dirty-reads)
      - [沒有髒寫](/tw/ch8/#sec_transactions_dirty_write)
      - [實現讀已提交](/tw/ch8/#sec_transactions_read_committed_impl)
    - [快照隔離與可重複讀](/tw/ch8/#sec_transactions_snapshot_isolation)
      - [多版本併發控制（MVCC）](/tw/ch8/#sec_transactions_snapshot_impl)
      - [觀察一致快照的可見性規則](/tw/ch8/#sec_transactions_mvcc_visibility)
      - [索引與快照隔離](/tw/ch8/#indexes-and-snapshot-isolation)
      - [快照隔離、可重複讀和命名混淆](/tw/ch8/#snapshot-isolation-repeatable-read-and-naming-confusion)
    - [防止丟失更新](/tw/ch8/#sec_transactions_lost_update)
      - [原子寫操作](/tw/ch8/#atomic-write-operations)
      - [顯式鎖定](/tw/ch8/#explicit-locking)
      - [自動檢測丟失更新](/tw/ch8/#automatically-detecting-lost-updates)
      - [條件寫入（比較並設定）](/tw/ch8/#sec_transactions_compare_and_set)
      - [衝突解決與複製](/tw/ch8/#conflict-resolution-and-replication)
    - [寫偏差與幻讀](/tw/ch8/#sec_transactions_write_skew)
      - [寫偏差的特徵](/tw/ch8/#characterizing-write-skew)
      - [寫偏差的更多例子](/tw/ch8/#more-examples-of-write-skew)
      - [導致寫偏差的幻讀](/tw/ch8/#sec_transactions_phantom)
      - [物化衝突](/tw/ch8/#materializing-conflicts)
  - [可序列化](/tw/ch8/#sec_transactions_serializability)
    - [實際序列執行](/tw/ch8/#sec_transactions_serial)
      - [將事務封裝在儲存過程中](/tw/ch8/#encapsulating-transactions-in-stored-procedures)
      - [儲存過程的利弊](/tw/ch8/#sec_transactions_stored_proc_tradeoffs)
      - [分片](/tw/ch8/#sharding)
      - [序列執行總結](/tw/ch8/#summary-of-serial-execution)
    - [兩階段鎖定（2PL）](/tw/ch8/#sec_transactions_2pl)
      - [兩階段鎖定的實現](/tw/ch8/#implementation-of-two-phase-locking)
      - [兩階段鎖定的效能](/tw/ch8/#performance-of-two-phase-locking)
      - [謂詞鎖](/tw/ch8/#predicate-locks)
      - [索引範圍鎖](/tw/ch8/#sec_transactions_2pl_range)
    - [可序列化快照隔離（SSI）](/tw/ch8/#sec_transactions_ssi)
      - [悲觀併發控制與樂觀併發控制](/tw/ch8/#pessimistic-versus-optimistic-concurrency-control)
      - [基於過時前提的決策](/tw/ch8/#decisions-based-on-an-outdated-premise)
      - [檢測陳舊的 MVCC 讀取](/tw/ch8/#detecting-stale-mvcc-reads)
      - [檢測影響先前讀取的寫入](/tw/ch8/#sec_detecting_writes_affect_reads)
      - [可序列化快照隔離的效能](/tw/ch8/#performance-of-serializable-snapshot-isolation)
  - [分散式事務](/tw/ch8/#sec_transactions_distributed)
    - [兩階段提交（2PC）](/tw/ch8/#sec_transactions_2pc)
      - [系統承諾](/tw/ch8/#a-system-of-promises)
      - [協調者失效](/tw/ch8/#coordinator-failure)
      - [三階段提交](/tw/ch8/#three-phase-commit)
    - [跨不同系統的分散式事務](/tw/ch8/#sec_transactions_xa)
      - [恰好一次訊息處理](/tw/ch8/#sec_transactions_exactly_once)
      - [XA 事務](/tw/ch8/#xa-transactions)
      - [存疑時持有鎖](/tw/ch8/#holding-locks-while-in-doubt)
      - [從協調者失效中恢復](/tw/ch8/#recovering-from-coordinator-failure)
      - [XA 事務的問題](/tw/ch8/#problems-with-xa-transactions)
    - [資料庫內部的分散式事務](/tw/ch8/#sec_transactions_internal)
      - [再談恰好一次訊息處理](/tw/ch8/#exactly-once-message-processing-revisited)
  - [總結](/tw/ch8/#summary)
    - [參考文獻](/tw/ch8/#references)
- [9 分散式系統的麻煩](/tw/ch9/)
  - [故障與部分失效](/tw/ch9/#sec_distributed_partial_failure)
  - [不可靠的網路](/tw/ch9/#sec_distributed_networks)
    - [TCP 的侷限性](/tw/ch9/#sec_distributed_tcp)
    - [實踐中的網路故障](/tw/ch9/#sec_distributed_network_faults)
    - [故障檢測](/tw/ch9/#id307)
    - [超時和無界延遲](/tw/ch9/#sec_distributed_queueing)
      - [網路擁塞與排隊](/tw/ch9/#network-congestion-and-queueing)
    - [同步網路與非同步網路](/tw/ch9/#sec_distributed_sync_networks)
      - [我們不能簡單地讓網路延遲可預測嗎？](/tw/ch9/#can-we-not-simply-make-network-delays-predictable)
  - [不可靠的時鐘](/tw/ch9/#sec_distributed_clocks)
    - [單調時鐘與日曆時鐘](/tw/ch9/#sec_distributed_monotonic_timeofday)
      - [日曆時鐘](/tw/ch9/#time-of-day-clocks)
      - [單調時鐘](/tw/ch9/#monotonic-clocks)
    - [時鐘同步和準確性](/tw/ch9/#sec_distributed_clock_accuracy)
    - [對同步時鐘的依賴](/tw/ch9/#sec_distributed_clocks_relying)
      - [用於事件排序的時間戳](/tw/ch9/#sec_distributed_lww)
      - [帶置信區間的時鐘讀數](/tw/ch9/#clock-readings-with-a-confidence-interval)
      - [用於全域性快照的同步時鐘](/tw/ch9/#sec_distributed_spanner)
    - [程序暫停](/tw/ch9/#sec_distributed_clocks_pauses)
      - [響應時間保證](/tw/ch9/#sec_distributed_clocks_realtime)
      - [限制垃圾回收的影響](/tw/ch9/#sec_distributed_gc_impact)
  - [知識、真相和謊言](/tw/ch9/#sec_distributed_truth)
    - [多數派原則](/tw/ch9/#sec_distributed_majority)
    - [分散式鎖和租約](/tw/ch9/#sec_distributed_lock_fencing)
      - [用柵欄機制隔離殭屍與延遲請求](/tw/ch9/#sec_distributed_fencing_tokens)
      - [多副本隔離](/tw/ch9/#fencing-with-multiple-replicas)
    - [拜占庭故障](/tw/ch9/#sec_distributed_byzantine)
      - [弱形式的謊言](/tw/ch9/#weak-forms-of-lying)
    - [系統模型與現實](/tw/ch9/#sec_distributed_system_model)
      - [定義演算法的正確性](/tw/ch9/#defining-the-correctness-of-an-algorithm)
      - [安全性與活性](/tw/ch9/#sec_distributed_safety_liveness)
      - [將系統模型對映到現實世界](/tw/ch9/#mapping-system-models-to-the-real-world)
    - [形式化方法和隨機測試](/tw/ch9/#sec_distributed_formal)
      - [模型檢查與規範語言](/tw/ch9/#model-checking-and-specification-languages)
      - [故障注入](/tw/ch9/#sec_fault_injection)
      - [確定性模擬測試](/tw/ch9/#deterministic-simulation-testing)
  - [總結](/tw/ch9/#summary)
    - [參考文獻](/tw/ch9/#參考文獻)
- [10 一致性與共識](/tw/ch10/)
  - [線性一致性](/tw/ch10/#sec_consistency_linearizability)
    - [什麼使系統具有線性一致性？](/tw/ch10/#sec_consistency_lin_definition)
    - [依賴線性一致性](/tw/ch10/#sec_consistency_linearizability_usage)
      - [鎖定與領導者選舉](/tw/ch10/#locking-and-leader-election)
      - [約束與唯一性保證](/tw/ch10/#sec_consistency_uniqueness)
      - [跨通道時序依賴](/tw/ch10/#cross-channel-timing-dependencies)
    - [實現線性一致性系統](/tw/ch10/#sec_consistency_implementing_linearizable)
      - [線性一致性與仲裁](/tw/ch10/#sec_consistency_quorum_linearizable)
    - [線性一致性的代價](/tw/ch10/#sec_linearizability_cost)
      - [CAP 定理](/tw/ch10/#the-cap-theorem)
      - [線性一致性與網路延遲](/tw/ch10/#linearizability-and-network-delays)
  - [ID 生成器和邏輯時鐘](/tw/ch10/#sec_consistency_logical)
    - [邏輯時鐘](/tw/ch10/#sec_consistency_timestamps)
      - [Lamport 時間戳](/tw/ch10/#lamport-timestamps)
      - [混合邏輯時鐘](/tw/ch10/#hybrid-logical-clocks)
      - [Lamport/混合邏輯時鐘 vs. 向量時鐘](/tw/ch10/#lamporthybrid-logical-clocks-vs-vector-clocks)
    - [線性一致的 ID 生成器](/tw/ch10/#sec_consistency_linearizable_id)
      - [實現線性一致的 ID 生成器](/tw/ch10/#implementing-a-linearizable-id-generator)
      - [使用邏輯時鐘強制約束](/tw/ch10/#enforcing-constraints-using-logical-clocks)
  - [共識](/tw/ch10/#sec_consistency_consensus)
    - [共識的多面性](/tw/ch10/#sec_consistency_faces)
      - [單值共識](/tw/ch10/#single-value-consensus)
      - [比較並設定作為共識](/tw/ch10/#compare-and-set-as-consensus)
      - [共享日誌作為共識](/tw/ch10/#sec_consistency_shared_logs)
      - [獲取並增加作為共識](/tw/ch10/#fetch-and-add-as-consensus)
      - [原子提交作為共識](/tw/ch10/#atomic-commitment-as-consensus)
    - [共識的實踐](/tw/ch10/#sec_consistency_total_order)
      - [使用共享日誌](/tw/ch10/#sec_consistency_smr)
      - [從單主複製到共識](/tw/ch10/#from-single-leader-replication-to-consensus)
      - [共識的微妙之處](/tw/ch10/#subtleties-of-consensus)
      - [共識的利弊](/tw/ch10/#pros-and-cons-of-consensus)
    - [協調服務](/tw/ch10/#sec_consistency_coordination)
      - [將工作分配給節點](/tw/ch10/#allocating-work-to-nodes)
      - [服務發現](/tw/ch10/#service-discovery)
  - [總結](/tw/ch10/#summary)
    - [參考文獻](/tw/ch10/#參考文獻)
- [III 派生資料](/tw/part-iii/)
  - [記錄系統和派生資料系統](/tw/part-iii/#記錄系統和派生資料系統)
  - [章節概述](/tw/part-iii/#章節概述)
  - [索引](/tw/part-iii/#索引)
  - [11. 批處理](/tw/part-iii/#11-批處理)
  - [12. 流處理](/tw/part-iii/#12-流處理)
  - [13. 流式系統的哲學](/tw/part-iii/#13-流式系統的哲學)
  - [14. 做正確的事情](/tw/part-iii/#14-做正確的事情)
- [11 批處理](/tw/ch11/)
  - [使用 Unix 工具的批處理](/tw/ch11/#sec_batch_unix)
    - [簡單日誌分析](/tw/ch11/#sec_batch_log_analysis)
    - [命令鏈與自定義程式](/tw/ch11/#sec_batch_custom_program)
    - [排序與記憶體聚合](/tw/ch11/#id275)
  - [分散式系統中的批處理](/tw/ch11/#sec_batch_distributed)
    - [分散式檔案系統](/tw/ch11/#sec_batch_dfs)
    - [物件儲存](/tw/ch11/#id277)
    - [分散式作業編排](/tw/ch11/#id278)
      - [資源分配](/tw/ch11/#id279)
      - [工作流排程](/tw/ch11/#sec_batch_workflows)
      - [故障處理](/tw/ch11/#id281)
  - [批處理模型](/tw/ch11/#id431)
    - [MapReduce](/tw/ch11/#sec_batch_mapreduce)
    - [資料流引擎](/tw/ch11/#sec_batch_dataflow)
    - [混洗資料](/tw/ch11/#sec_shuffle)
      - [JOIN 與 GROUP BY](/tw/ch11/#sec_batch_join)
    - [查詢語言](/tw/ch11/#sec_batch_query_lanauges)
    - [資料框](/tw/ch11/#id287)
  - [批處理用例](/tw/ch11/#sec_batch_output)
    - [提取—轉換—載入（ETL）](/tw/ch11/#sec_batch_etl_usage)
    - [分析](/tw/ch11/#sec_batch_olap)
    - [機器學習](/tw/ch11/#id290)
    - [對外提供衍生資料](/tw/ch11/#sec_batch_serving_derived)
  - [本章小結](/tw/ch11/#id292)
    - [腳註](/tw/ch11/#腳註)
    - [參考文獻](/tw/ch11/#references)
- [12 流處理](/tw/ch12/)
  - [傳遞事件流](/tw/ch12/#sec_stream_transmit)
    - [訊息傳遞系統](/tw/ch12/#sec_stream_messaging)
      - [直接從生產者傳遞給消費者](/tw/ch12/#id296)
      - [訊息代理](/tw/ch12/#id433)
      - [訊息代理與資料庫的對比](/tw/ch12/#id297)
      - [多個消費者](/tw/ch12/#id298)
      - [確認應答與重新傳遞](/tw/ch12/#sec_stream_reordering)
    - [基於日誌的訊息代理](/tw/ch12/#sec_stream_log)
      - [使用日誌進行訊息儲存](/tw/ch12/#id300)
      - [日誌與傳統訊息傳遞的比較](/tw/ch12/#sec_stream_logs_vs_messaging)
      - [消費者偏移量](/tw/ch12/#sec_stream_log_offsets)
      - [磁碟空間使用](/tw/ch12/#sec_stream_disk_usage)
      - [當消費者跟不上生產者時](/tw/ch12/#id459)
      - [重播舊訊息](/tw/ch12/#sec_stream_replay)
  - [資料庫與流](/tw/ch12/#sec_stream_databases)
    - [保持系統同步](/tw/ch12/#sec_stream_sync)
    - [變更資料捕獲](/tw/ch12/#sec_stream_cdc)
      - [變更資料捕獲的實現](/tw/ch12/#id307)
      - [初始快照](/tw/ch12/#sec_stream_cdc_snapshot)
      - [日誌壓實](/tw/ch12/#sec_stream_log_compaction)
      - [變更流的 API 支援](/tw/ch12/#sec_stream_change_api)
      - [變更資料捕獲與事件溯源](/tw/ch12/#sec_stream_event_sourcing)
    - [狀態、流和不變性](/tw/ch12/#sec_stream_immutability)
      - [不可變事件的優點](/tw/ch12/#sec_stream_immutability_pros)
      - [從同一事件日誌中派生多個檢視](/tw/ch12/#sec_stream_deriving_views)
      - [併發控制](/tw/ch12/#sec_stream_concurrency)
      - [不變性的侷限](/tw/ch12/#sec_stream_immutability_limitations)
  - [流處理](/tw/ch12/#sec_stream_processing)
    - [流處理的應用](/tw/ch12/#sec_stream_uses)
      - [複合事件處理](/tw/ch12/#id317)
      - [流分析](/tw/ch12/#id318)
      - [維護物化檢視](/tw/ch12/#sec_stream_mat_view)
      - [在流上搜尋](/tw/ch12/#id320)
      - [事件驅動架構與 RPC](/tw/ch12/#sec_stream_actors_drpc)
    - [時間推理](/tw/ch12/#sec_stream_time)
      - [事件時間與處理時間](/tw/ch12/#id322)
      - [處理滯留事件](/tw/ch12/#id323)
      - [你用的是誰的時鐘？](/tw/ch12/#id438)
      - [視窗的型別](/tw/ch12/#id324)
    - [流連線](/tw/ch12/#sec_stream_joins)
      - [流流連線（視窗連線）](/tw/ch12/#id440)
      - [流表連線（流擴充）](/tw/ch12/#sec_stream_table_joins)
      - [表表連線（維護物化檢視）](/tw/ch12/#id326)
      - [連線的時間依賴性](/tw/ch12/#sec_stream_join_time)
    - [容錯](/tw/ch12/#sec_stream_fault_tolerance)
      - [微批處理與檢查點](/tw/ch12/#id329)
      - [再談原子提交](/tw/ch12/#sec_stream_atomic_commit)
      - [冪等性](/tw/ch12/#sec_stream_idempotence)
      - [失敗後重建狀態](/tw/ch12/#sec_stream_state_fault_tolerance)
  - [本章小結](/tw/ch12/#id332)
    - [腳註](/tw/ch12/#腳註)
    - [參考文獻](/tw/ch12/#references)
- [13 流式系統的哲學](/tw/ch13/)
  - [資料整合](/tw/ch13/#sec_future_integration)
    - [透過衍生資料組合專用工具](/tw/ch13/#id442)
      - [理解資料流](/tw/ch13/#id443)
      - [衍生資料與分散式事務](/tw/ch13/#sec_future_derived_vs_transactions)
      - [全序的侷限](/tw/ch13/#id335)
      - [排序事件以捕獲因果關係](/tw/ch13/#sec_future_capture_causality)
    - [批處理與流處理](/tw/ch13/#sec_future_batch_streaming)
      - [維護衍生狀態](/tw/ch13/#id446)
      - [為應用演化而重新處理資料](/tw/ch13/#sec_future_reprocessing)
      - [統一批處理與流處理](/tw/ch13/#id338)
  - [分拆資料庫](/tw/ch13/#sec_future_unbundling)
    - [組合使用資料儲存技術](/tw/ch13/#id447)
      - [建立索引](/tw/ch13/#id340)
      - [一切的後設資料庫](/tw/ch13/#id341)
      - [讓分拆行得通](/tw/ch13/#sec_future_unbundling_favor)
      - [分拆式系統與整合式系統](/tw/ch13/#id448)
    - [圍繞資料流設計應用](/tw/ch13/#sec_future_dataflow)
      - [應用程式碼作為衍生函式](/tw/ch13/#sec_future_dataflow_derivation)
      - [分離應用程式碼與狀態](/tw/ch13/#id344)
      - [資料流：狀態變更與應用程式碼的相互作用](/tw/ch13/#id450)
      - [流處理器與服務](/tw/ch13/#id345)
    - [觀察衍生狀態](/tw/ch13/#sec_future_observing)
      - [物化檢視與快取](/tw/ch13/#id451)
      - [有狀態、可離線的客戶端](/tw/ch13/#id347)
      - [將狀態變更推送給客戶端](/tw/ch13/#id348)
      - [端到端事件流](/tw/ch13/#id349)
      - [讀也是事件](/tw/ch13/#sec_future_read_events)
      - [多分片資料處理](/tw/ch13/#sec_future_unbundled_multi_shard)
  - [追求正確性](/tw/ch13/#sec_future_correctness)
    - [資料庫的端到端原則](/tw/ch13/#sec_future_end_to_end)
      - [恰好一次執行操作](/tw/ch13/#id353)
      - [抑制重複](/tw/ch13/#id354)
        - [例 13-1. 從一個賬戶向另一個賬戶非冪等地轉賬](/tw/ch13/#例-13-1-從一個賬戶向另一個賬戶非冪等地轉賬)
      - [唯一標識請求](/tw/ch13/#id355)
        - [例 13-2. 使用唯一 ID 抑制重複請求](/tw/ch13/#例-13-2-使用唯一-id-抑制重複請求)
      - [端到端原則](/tw/ch13/#sec_future_e2e_argument)
      - [在資料系統中應用端到端思維](/tw/ch13/#id357)
    - [強制約束](/tw/ch13/#sec_future_constraints)
      - [唯一性約束需要共識](/tw/ch13/#id452)
      - [基於日誌的訊息傳遞中的唯一性](/tw/ch13/#sec_future_uniqueness_log)
      - [多分片請求處理](/tw/ch13/#id360)
    - [及時性與完整性](/tw/ch13/#sec_future_integrity)
      - [資料流系統的正確性](/tw/ch13/#id453)
      - [寬鬆解釋約束](/tw/ch13/#id362)
      - [避免協調的資料系統](/tw/ch13/#id454)
    - [信任但驗證](/tw/ch13/#sec_future_verification)
      - [面對軟體缺陷時維護完整性](/tw/ch13/#id455)
      - [不要盲信承諾](/tw/ch13/#id364)
      - [為可審計性而設計](/tw/ch13/#id365)
      - [再談端到端原則](/tw/ch13/#id456)
      - [可審計資料系統的工具](/tw/ch13/#id366)
  - [本章小結](/tw/ch13/#id367)
    - [腳註](/tw/ch13/#腳註)
    - [參考文獻](/tw/ch13/#references)
- [14 做正確的事情](/tw/ch14/)
  - [預測分析](/tw/ch14/#id369)
    - [偏見與歧視](/tw/ch14/#id370)
    - [責任與問責](/tw/ch14/#id371)
    - [反饋迴圈](/tw/ch14/#id372)
  - [隱私與追蹤](/tw/ch14/#id373)
    - [監視](/tw/ch14/#id374)
    - [同意與選擇自由](/tw/ch14/#id375)
    - [隱私與資料使用](/tw/ch14/#id457)
    - [資料資產與權力](/tw/ch14/#id376)
    - [回顧工業革命](/tw/ch14/#id377)
    - [立法與自律](/tw/ch14/#sec_future_legislation)
  - [總結](/tw/ch14/#id594)
    - [腳註](/tw/ch14/#腳註)
    - [參考文獻](/tw/ch14/#references)
- [術語表](/tw/glossary/)
  - [非同步（asynchronous）](/tw/glossary/#非同步asynchronous)
  - [原子（atomic）](/tw/glossary/#原子atomic)
  - [背壓（backpressure）](/tw/glossary/#背壓backpressure)
  - [批處理（batch process）](/tw/glossary/#批處理batch-process)
  - [有界（bounded）](/tw/glossary/#有界bounded)
  - [拜占庭故障（Byzantine fault）](/tw/glossary/#拜占庭故障byzantine-fault)
  - [快取（cache）](/tw/glossary/#快取cache)
  - [CAP 定理（CAP theorem）](/tw/glossary/#cap-定理cap-theorem)
  - [因果關係（causality）](/tw/glossary/#因果關係causality)
  - [共識（consensus）](/tw/glossary/#共識consensus)
  - [資料倉儲（data warehouse）](/tw/glossary/#資料倉儲data-warehouse)
  - [宣告式（declarative）](/tw/glossary/#宣告式declarative)
  - [反正規化（denormalize）](/tw/glossary/#反正規化denormalize)
  - [派生資料（derived data）](/tw/glossary/#派生資料derived-data)
  - [確定性（deterministic）](/tw/glossary/#確定性deterministic)
  - [分散式（distributed）](/tw/glossary/#分散式distributed)
  - [永續性（durable）](/tw/glossary/#永續性durable)
  - [ETL](/tw/glossary/#etl)
  - [故障切換（failover）](/tw/glossary/#故障切換failover)
  - [容錯（fault-tolerant）](/tw/glossary/#容錯fault-tolerant)
  - [流量控制（flow control）](/tw/glossary/#流量控制flow-control)
  - [追隨者（follower）](/tw/glossary/#追隨者follower)
  - [全文檢索（full-text search）](/tw/glossary/#全文檢索full-text-search)
  - [圖（graph）](/tw/glossary/#圖graph)
  - [雜湊（hash）](/tw/glossary/#雜湊hash)
  - [冪等（idempotent）](/tw/glossary/#冪等idempotent)
  - [索引（index）](/tw/glossary/#索引index)
  - [隔離性（isolation）](/tw/glossary/#隔離性isolation)
  - [連線（join）](/tw/glossary/#連線join)
  - [領導者（leader）](/tw/glossary/#領導者leader)
  - [線性一致（linearizable）](/tw/glossary/#線性一致linearizable)
  - [區域性（locality）](/tw/glossary/#區域性locality)
  - [鎖（lock）](/tw/glossary/#鎖lock)
  - [日誌（log）](/tw/glossary/#日誌log)
  - [物化（materialize）](/tw/glossary/#物化materialize)
  - [節點（node）](/tw/glossary/#節點node)
  - [正規化（normalized）](/tw/glossary/#正規化normalized)
  - [OLAP](/tw/glossary/#olap)
  - [OLTP](/tw/glossary/#oltp)
  - [分片（sharding）](/tw/glossary/#分片sharding)
  - [百分位（percentile）](/tw/glossary/#百分位percentile)
  - [主鍵（primary key）](/tw/glossary/#主鍵primary-key)
  - [法定票數（quorum）](/tw/glossary/#法定票數quorum)
  - [再平衡（rebalance）](/tw/glossary/#再平衡rebalance)
  - [複製（replication）](/tw/glossary/#複製replication)
  - [模式（schema）](/tw/glossary/#模式schema)
  - [二級索引（secondary index）](/tw/glossary/#二級索引secondary-index)
  - [可序列化（serializable）](/tw/glossary/#可序列化serializable)
  - [無共享（shared-nothing）](/tw/glossary/#無共享shared-nothing)
  - [偏斜（skew）](/tw/glossary/#偏斜skew)
  - [腦裂（split brain）](/tw/glossary/#腦裂split-brain)
  - [儲存過程（stored procedure）](/tw/glossary/#儲存過程stored-procedure)
  - [流處理（stream process）](/tw/glossary/#流處理stream-process)
  - [同步（synchronous）](/tw/glossary/#同步synchronous)
  - [記錄系統（system of record）](/tw/glossary/#記錄系統system-of-record)
  - [超時（timeout）](/tw/glossary/#超時timeout)
  - [全序（total order）](/tw/glossary/#全序total-order)
  - [事務（transaction）](/tw/glossary/#事務transaction)
  - [兩階段提交（two-phase commit, 2PC）](/tw/glossary/#兩階段提交two-phase-commit-2pc)
  - [兩階段鎖（two-phase locking, 2PL）](/tw/glossary/#兩階段鎖two-phase-locking-2pl)
  - [無界（unbounded）](/tw/glossary/#無界unbounded)
- [索引](/tw/indexes/)
  - [符號](/tw/indexes/#符號)
  - [A](/tw/indexes/#a)
  - [B](/tw/indexes/#b)
  - [C](/tw/indexes/#c)
  - [D](/tw/indexes/#d)
  - [E](/tw/indexes/#e)
  - [F](/tw/indexes/#f)
  - [G](/tw/indexes/#g)
  - [H](/tw/indexes/#h)
  - [I](/tw/indexes/#i)
  - [J](/tw/indexes/#j)
  - [K](/tw/indexes/#k)
  - [L](/tw/indexes/#l)
  - [M](/tw/indexes/#m)
  - [N](/tw/indexes/#n)
  - [O](/tw/indexes/#o)
  - [P](/tw/indexes/#p)
  - [Q](/tw/indexes/#q)
  - [R](/tw/indexes/#r)
  - [S](/tw/indexes/#s)
  - [T](/tw/indexes/#t)
  - [U](/tw/indexes/#u)
  - [V](/tw/indexes/#v)
  - [W](/tw/indexes/#w)
  - [X](/tw/indexes/#x)
  - [Y](/tw/indexes/#y)
  - [Z](/tw/indexes/#z)
- [後記](/tw/colophon/)
  - [關於作者](/tw/colophon/#關於作者)
  - [關於譯者](/tw/colophon/#關於譯者)
  - [後記](/tw/colophon/#後記)
- [貢獻者](/tw/contrib/)
  - [譯者](/tw/contrib/#譯者)
  - [校訂與維護](/tw/contrib/#校訂與維護)
  - [繁體中文版本](/tw/contrib/#繁體中文版本)
  - [貢獻列表](/tw/contrib/#貢獻列表)

## 插圖目錄 {#list-of-figures}

全書編號插圖使用穩定圖號和錨點；正文中的“圖 N-N”引用會同時連結到這裡列出的目標。

- [圖 1-1](/tw/ch1/#fig_dwh_etl) — 將資料透過 ETL 匯入資料倉儲的簡化示意圖。
- [圖 1-2](/tw/ch1/#fig_cloud_spectrum) — 軟體型別及其運維方式的連續譜。
- [圖 2-1](/tw/ch2/#fig_twitter_relational) — 一個允許使用者相互關注的社交網路的簡單關係模式。
- [圖 2-2](/tw/ch2/#fig_twitter_timelines) — 扇出——把新帖子投遞給發帖使用者的每一位關注者。
- [圖 2-3](/tw/ch2/#fig_throughput) — 當服務的吞吐量接近其處理能力上限時，排隊會使響應時間急劇增加。
- [圖 2-4](/tw/ch2/#fig_response_time) — 響應時間、服務時間、網路延遲和排隊延遲。
- [圖 2-5](/tw/ch2/#fig_lognormal) — 用 100 次服務請求的響應時間樣本說明平均值和分位數。
- [圖 2-6](/tw/ch2/#fig_tail_amplification) — 當一次請求需要多個後端呼叫時，只需一個慢呼叫，就會拖慢整個終端使用者請求。
- [圖 3-1](/tw/ch3/#fig_obama_relational) — 使用關係模式表示 LinkedIn 個人資料。
- [圖 3-2](/tw/ch3/#fig_json_tree) — 一對多關係形成樹狀結構。
- [圖 3-3](/tw/ch3/#fig_datamodels_m2m_rel) — 關係模型中的多對多關係。
- [圖 3-4](/tw/ch3/#fig_datamodels_many_to_many) — 文件模型中的多對多關係；每個虛線框內的資料可以組成一份文件。
- [圖 3-5](/tw/ch3/#fig_dwh_schema) — 用於資料倉儲的星型模式示例。
- [圖 3-6](/tw/ch3/#fig_datamodels_graph) — 圖結構資料示例（框表示頂點，箭頭表示邊）。
- [圖 3-7](/tw/ch3/#fig_datalog_naive) — 使用示例 3\-12 中的 Datalog 規則確定愛達荷州在北美。
- [圖 3-8](/tw/ch3/#fig_event_sourcing) — 以不可變事件日誌作為權威資料來源，並從中派生物化檢視。
- [圖 3-9](/tw/ch3/#fig_dataframe_to_matrix) — 將電影評分的關聯式資料庫轉換為矩陣表示。
- [圖 4-1](/tw/ch4/#fig_storage_csv_hash_index) — 以類似 CSV 的格式儲存鍵值對日誌，並使用記憶體雜湊對映建立索引。
- [圖 4-2](/tw/ch4/#fig_storage_sstable_index) — 帶有稀疏索引的 SSTable，查詢可以直接跳到正確的資料塊。
- [圖 4-3](/tw/ch4/#fig_storage_sstable_merging) — 合併多個 SSTable 段，僅保留每個鍵的最新值。
- [圖 4-4](/tw/ch4/#fig_storage_bloom) — 布隆過濾器以機率方式快速判斷某個鍵是否存在於某個 SSTable 中。
- [圖 4-5](/tw/ch4/#fig_storage_b_tree) — 使用 B 樹索引查詢鍵 251。先從根頁沿引用進入鍵 200–300 所在的頁，再進入鍵 250–270 所在的頁。
- [圖 4-6](/tw/ch4/#fig_storage_b_tree_split) — 在邊界鍵 337 處拆分頁，使 B 樹增長；父頁也隨之更新，以引用兩個子頁。
- [圖 4-7](/tw/ch4/#fig_column_store) — 按列而不是按行儲存關係資料。
- [圖 4-8](/tw/ch4/#fig_bitmap_index) — 對單列進行壓縮並建立點陣圖索引的儲存方式。
- [圖 4-9](/tw/ch4/#fig_bitmap_and) — 兩張點陣圖的按位與運算非常適合向量化處理。
- [圖 4-10](/tw/ch4/#fig_data_cube) — 多維資料集的兩個維度，透過求和聚合資料。
- [圖 4-11](/tw/ch4/#fig_vector_hnsw) — 在 HNSW 索引中查詢最接近給定查詢向量的資料庫條目。
- [圖 5-1](/tw/ch5/#fig_encoding_preserve_field) — 舊版應用程式更新先前由新版應用程式寫入的資料時，若處理不慎，可能丟失資料。
- [圖 5-2](/tw/ch5/#fig_encoding_messagepack) — 示例 5\-2 中的記錄使用 MessagePack 編碼後的結果。
- [圖 5-3](/tw/ch5/#fig_encoding_protobuf) — 使用 Protocol Buffers 編碼的示例記錄。
- [圖 5-4](/tw/ch5/#fig_encoding_avro) — 使用 Avro 編碼的示例記錄。
- [圖 5-5](/tw/ch5/#fig_encoding_avro_schemas) — Protocol Buffers 的編碼與解碼可以使用不同版本的模式。Avro 解碼時使用兩個模式：寫入者模式必須與編碼時所用模式完全相同，讀取者模式則可以是較舊或較新的版本。
- [圖 5-6](/tw/ch5/#fig_encoding_avro_resolution) — Avro 讀取器協調寫入者模式與讀取者模式之間的差異。
- [圖 5-7](/tw/ch5/#fig_encoding_workflow) — 使用圖形化的業務流程模型與標記法（BPMN）表示工作流的示例。
- [圖 II-1](/tw/part-ii/#fig_replication_partitioning) — 一個資料庫切分為兩個分割槽，每個分割槽都有兩個副本
- [圖 6-1](/tw/ch6/#fig_replication_leader_follower) — 單主複製把所有寫入都發往指定的領導者，再由領導者將變更流傳送給各追隨者副本。
- [圖 6-2](/tw/ch6/#fig_replication_sync_replication) — 基於領導者的複製，其中一個追隨者同步複製，另一個非同步複製。
- [圖 6-3](/tw/ch6/#fig_replication_read_your_writes) — 使用者寫入後，又從陳舊副本讀取。要防止這種異常，需要寫後讀一致性。
- [圖 6-4](/tw/ch6/#fig_replication_monotonic_reads) — 使用者先從較新的副本讀取，隨後從陳舊副本讀取，時間彷彿倒退了。要防止這種異常，需要單調讀。
- [圖 6-5](/tw/ch6/#fig_replication_consistent_prefix) — 如果某些分片的複製速度慢於其他分片，觀察者可能先看到答案，後看到問題。
- [圖 6-6](/tw/ch6/#fig_replication_multi_dc) — 跨多個地區的多主複製。
- [圖 6-7](/tw/ch6/#fig_replication_topologies) — 多主複製可以採用的三種拓撲示例。
- [圖 6-8](/tw/ch6/#fig_replication_causality) — 在多主複製中，寫入抵達某些副本的順序可能有誤。
- [圖 6-9](/tw/ch6/#fig_replication_write_conflict) — 兩個領導者併發更新同一條記錄，造成寫入衝突。
- [圖 6-10](/tw/ch6/#fig_replication_amazon_anomaly) — 亞馬遜購物車異常示例：以並集方式合併購物車衝突時，已刪除的商品可能重新出現。
- [圖 6-11](/tw/ch6/#fig_replication_ot_crdt) — OT 與 CRDT 分別如何合併字串中的兩次併發插入。
- [圖 6-12](/tw/ch6/#fig_replication_quorum_node_outage) — 節點停機後的仲裁寫、仲裁讀和讀修復。
- [圖 6-13](/tw/ch6/#fig_replication_quorum_overlap) — 如果 w \+ r \> n，讀取的 r 個副本中至少有一個必然見過最近一次成功寫入。
- [圖 6-14](/tw/ch6/#fig_replication_concurrency) — Dynamo 風格資料儲存中的併發寫入沒有明確定義的順序。
- [圖 6-15](/tw/ch6/#fig_replication_causality_single) — 捕獲兩個客戶端併發編輯購物車時的因果依賴。
- [圖 6-16](/tw/ch6/#fig_replication_causal_dependencies) — 圖 6\-15 中因果依賴關係的圖示。
- [圖 7-1](/tw/ch7/#fig_sharding_replicas) — 複製與分片結合使用：每個節點對某些分片充當領導者，對另一些分片充當追隨者。
- [圖 7-2](/tw/ch7/#fig_sharding_encyclopedia) — 印刷版百科全書按鍵範圍分片。
- [圖 7-3](/tw/ch7/#fig_sharding_hash_mod_n) — 透過對鍵進行雜湊並取模節點數來將鍵分配給節點。更改節點數會導致許多鍵從一個節點移動到另一個節點。
- [圖 7-4](/tw/ch7/#fig_sharding_rebalance_fixed) — 向每個節點有多個分片的資料庫叢集新增新節點。
- [圖 7-5](/tw/ch7/#fig_sharding_hash_range) — 為每個分片分配連續的雜湊值範圍。
- [圖 7-6](/tw/ch7/#fig_sharding_cassandra) — Cassandra 和 ScyllaDB 將可能的雜湊值範圍（這裡是 0–1023）拆成邊界隨機的連續區間，併為每個節點分配多個區間。
- [圖 7-7](/tw/ch7/#fig_sharding_routing) — 將請求路由到正確節點的三種不同方式。
- [圖 7-8](/tw/ch7/#fig_sharding_zookeeper) — 使用 ZooKeeper 跟蹤分片到節點的分配。
- [圖 7-9](/tw/ch7/#fig_sharding_local_secondary) — 本地二級索引：每個分片只索引其自己分片內的記錄。
- [圖 7-10](/tw/ch7/#fig_sharding_global_secondary) — 全域性二級索引反映來自所有分片的資料，並且本身按索引值進行分片。
- [圖 8-1](/tw/ch8/#fig_transactions_increment) — 兩個客戶端併發遞增計數器之間的競態條件。
- [圖 8-2](/tw/ch8/#fig_transactions_read_uncommitted) — 違反隔離性：一個事務讀取另一個事務的未提交寫入（“髒讀”）。
- [圖 8-3](/tw/ch8/#fig_transactions_atomicity) — 原子性確保如果發生錯誤，該事務的任何先前寫入都會被撤消，以避免不一致的狀態。
- [圖 8-4](/tw/ch8/#fig_transactions_read_committed) — 沒有髒讀：使用者 2 只有在使用者 1 的事務提交後才能看到 x 的新值。
- [圖 8-5](/tw/ch8/#fig_transactions_dirty_writes) — 發生髒寫時，不同事務的衝突寫入可能混雜在一起。
- [圖 8-6](/tw/ch8/#fig_transactions_item_many_preceders) — 讀偏差：Aaliyah 觀察到了資料庫的不一致狀態。
- [圖 8-7](/tw/ch8/#fig_transactions_mvcc) — 使用多版本併發控制實現快照隔離。
- [圖 8-8](/tw/ch8/#fig_transactions_write_skew) — 寫偏差導致應用程式錯誤的示例。
- [圖 8-9](/tw/ch8/#fig_transactions_stored_proc) — 互動式事務與儲存過程的差異（採用圖 8\-8中的示例事務）。
- [圖 8-10](/tw/ch8/#fig_transactions_detect_mvcc) — 檢測事務何時從 MVCC 快照讀取過時值。
- [圖 8-11](/tw/ch8/#fig_transactions_detect_index_range) — 在可序列化快照隔離中，檢測一個事務何時修改了另一個事務讀過的資料。
- [圖 8-12](/tw/ch8/#fig_transactions_non_atomic) — 當事務涉及多個資料庫節點時，它可能在某些節點上提交，在其他節點上失敗。
- [圖 8-13](/tw/ch8/#fig_transactions_two_phase_commit) — 兩階段提交（2PC）的成功執行。
- [圖 8-14](/tw/ch8/#fig_transactions_2pc_crash) — 參與者投票“是”之後，協調者崩潰。資料庫 1 不知道該提交還是中止。
- [圖 9-1](/tw/ch9/#fig_distributed_network) — 發出請求卻沒有收到響應時，無法分辨究竟是 \(a\) 請求丟失、\(b\) 遠端節點宕機，還是 \(c\) 響應丟失。
- [圖 9-2](/tw/ch9/#fig_distributed_switch_queueing) — 多臺機器向同一個目的地傳送網路流量時，交換機佇列可能被塞滿。圖中埠 1、2 和 4 都在嘗試向埠 3 傳送資料包。
- [圖 9-3](/tw/ch9/#fig_distributed_timestamps) — 客戶端 B 的寫入在因果關係上晚於客戶端 A 的寫入，但 B 的寫入具有更早的時間戳。
- [圖 9-4](/tw/ch9/#fig_distributed_lease_pause) — 分散式鎖的錯誤實現：租約已經過期，客戶端 1 卻認為它依然有效，因而損壞了儲存中的檔案。
- [圖 9-5](/tw/ch9/#fig_distributed_lease_delay) — 原租約持有者發出的訊息可能延遲很久，直到另一個節點接管租約後才抵達。
- [圖 9-6](/tw/ch9/#fig_distributed_fencing) — 只允許寫入按照遞增的柵欄令牌順序執行，從而保證儲存訪問安全。
- [圖 9-7](/tw/ch9/#fig_distributed_fencing_leaderless) — 使用柵欄令牌保護對無主複製資料庫的寫入。
- [圖 10-1](/tw/ch10/#fig_consistency_linearizability_0) — 如果這個資料庫滿足線性一致性，那麼 Alice 的讀取應返回 1 而不是 0，或者 Bob 的讀取應返回 0 而不是 1。
- [圖 10-2](/tw/ch10/#fig_consistency_linearizability_1) — 如果讀請求與寫請求併發，則可能返回舊值，也可能返回新值。
- [圖 10-3](/tw/ch10/#fig_consistency_linearizability_2) — 如果 Alice 和 Bob 擁有完美時鐘，線性一致性要求讀取返回 x \= 1，因為對 x 的讀取開始於 x \= 1 寫入完成之後。
- [圖 10-4](/tw/ch10/#fig_consistency_linearizability_3) — 對 x 的讀取與 x \= 1 的寫入併發。由於不知道操作的確切時序，讀取可以返回 0 或 1。
- [圖 10-5](/tw/ch10/#fig_consistency_transcoder) — 一個不滿足線性一致性的系統：Alice 和 Bob 在不同時刻看到上傳的影象，因此 Bob 的請求建立在陳舊資料之上。
- [圖 10-6](/tw/ch10/#fig_consistency_leaderless) — 當網路延遲變化不定時，僅靠法定人數不足以保證線性一致性。
- [圖 10-7](/tw/ch10/#fig_consistency_cap_availability) — 如果網路分割槽使客戶端無法聯絡足夠多的副本，它們就無法處理寫入。
- [圖 10-8](/tw/ch10/#fig_consistency_id_generator) — 兩個不同節點可能生成相互衝突的 ID。
- [圖 10-9](/tw/ch10/#fig_consistency_lamport_ts) — Lamport 時間戳給出了與因果關係一致的全序。
- [圖 10-10](/tw/ch10/#fig_consistency_permissions) — 一個使用 Lamport 時間戳的許可權系統。
- [圖 11-1](/tw/ch11/#fig_batch_mapreduce) — 一個包含三個 mapper 和三個 reducer 的 MapReduce 作業。
- [圖 11-2](/tw/ch11/#fig_batch_join_example) — 使用者活動日誌與使用者畫像資料庫的連線。
- [圖 11-3](/tw/ch11/#fig_batch_join_reduce) — 基於使用者 ID 的排序合併連線。若輸入資料集由多個檔案分片組成，可並行啟動多個 mapper 處理。
- [圖 12-1](/tw/ch12/#fig_stream_multi_consumer) — （a）負載均衡：由多個消費者分擔一個主題的消費工作；（b）扇出：將每條訊息傳遞給多個消費者。
- [圖 12-2](/tw/ch12/#fig_stream_redelivery) — 消費者 2 在處理 m3 時崩潰，因此 m3 稍後被重新傳遞給消費者 1。
- [圖 12-3](/tw/ch12/#fig_stream_kafka_partitions) — 生產者把訊息追加到主題分割槽檔案中，消費者則順序讀取這些檔案。
- [圖 12-4](/tw/ch12/#fig_stream_write_order) — 資料庫中的 X 先被設為 A，再被設為 B；寫入到達搜尋索引的順序卻恰好相反。
- [圖 12-5](/tw/ch12/#fig_stream_change_capture) — 按資料寫入一個資料庫的順序取得資料，再按相同順序將變化應用到其他系統。
- [圖 12-6](/tw/ch12/#fig_stream_compaction) — 一個鍵值對日誌：鍵是貓咪影片的 ID（mew、purr、scratch 或 yawn），值是播放次數。日誌壓實只保留每個鍵的最新值。
- [圖 12-7](/tw/ch12/#fig_stream_integral) — 應用當前狀態與事件流之間的關係。
- [圖 12-8](/tw/ch12/#fig_stream_processing_time) — 按處理時間劃分視窗，會因處理速率的變化而產生人為假象。
- [圖 13-1](/tw/ch13/#fig_future_write_read_paths) — 在搜尋索引中，寫入（文件更新）與讀取（查詢）相遇。
- [圖 13-2](/tw/ch13/#fig_future_multi_shard) — 使用事件日誌和流處理器，檢查源賬戶是否有足夠餘額，並把資金原子地轉入目標賬戶和手續費賬戶。

## 表格目錄 {#list-of-tables}

- [表 1-1](/tw/ch1/#tab_oltp_vs_olap) — 事務型系統與分析型系統的特徵比較
- [表 1-2](/tw/ch1/#tab_cloud_native_dbs) — 自託管資料庫系統與雲原生資料庫系統示例
- [表 8-1](/tw/ch8/#ch_transactions_isolation_levels) — 各種隔離級別下可能發生的異常彙總。

## 示例目錄 {#list-of-examples}

- [範例 3-1](/tw/ch3/#fig_obama_json) — 將 LinkedIn 個人資料表示為 JSON 文件
- [範例 3-2](/tw/ch3/#fig_datamodels_m2m_json) — 透過 ID 引用組織的簡歷
- [範例 3-3](/tw/ch3/#fig_graph_sql_schema) — 使用關係模式表示屬性圖
- [範例 3-4](/tw/ch3/#fig_cypher_create) — 圖 3\-6 中的一部分資料，以 Cypher 查詢表示
- [範例 3-5](/tw/ch3/#fig_cypher_query) — 查詢從美國移居歐洲者的 Cypher 查詢
- [範例 3-6](/tw/ch3/#fig_graph_sql_query) — 使用遞迴公用表表示式，以 SQL 寫出與示例 3\-5 相同的查詢
- [範例 3-7](/tw/ch3/#fig_graph_n3_triples) — 圖 3\-6 中的一部分資料，以 Turtle 三元組表示
- [範例 3-8](/tw/ch3/#fig_graph_n3_shorthand) — 示例 3\-7 中資料的簡潔寫法
- [範例 3-9](/tw/ch3/#fig_graph_rdf_xml) — 使用 RDF\/XML 語法表示示例 3\-8 中的資料
- [範例 3-10](/tw/ch3/#fig_sparql_query) — 與示例 3\-5 相同的查詢，用 SPARQL 表示
- [範例 3-11](/tw/ch3/#fig_datalog_triples) — 圖 3\-6 中資料的子集，表示為 Datalog 事實
- [範例 3-12](/tw/ch3/#fig_datalog_query) — 與示例 3\-5 相同的查詢，用 Datalog 表示
- [範例 3-13](/tw/ch3/#fig_graphql_query) — 群聊應用的 GraphQL 查詢示例
- [範例 3-14](/tw/ch3/#fig_graphql_response) — 對示例 3\-13 中查詢的一種可能響應
- [範例 4-1](/tw/ch4/#fig_storage_analytics_query) — 分析人們在一週中的哪一天更傾向於購買新鮮水果或糖果
- [範例 5-1](/tw/ch5/#fig_encoding_json_schema) — 以整數為鍵、字串為值的 JSON 模式示例。由於 JSON 模式要求所有鍵均為字串，整數鍵表示為只包含數字的字串。
- [範例 5-2](/tw/ch5/#fig_encoding_json) — 本章將使用多種二進位制格式編碼的示例記錄
- [範例 5-3](/tw/ch5/#fig_open_api_def) — 使用 YAML 編寫的 OpenAPI 服務定義示例
- [範例 5-4](/tw/ch5/#fig_fastapi_def) — 使用 FastAPI 實現示例 5\-3 中定義的服務
- [範例 5-5](/tw/ch5/#fig_temporal_workflow) — 用於圖 5\-7 所示支付工作流的 Temporal 工作流定義片段
- [範例 8-1](/tw/ch8/#fig_transactions_select_for_update) — 顯式鎖定行以防止丟失更新
- [範例 8-2](/tw/ch8/#fig_transactions_meeting_rooms) — 會議室預訂系統試圖避免重複預訂（在快照隔離下並不安全）
