尤川豪   ·  5年前
445 貼文  ·  275 留言

「反正規化」作為「快取」機制的一種

需要設計一個類似動態時報的功能 多種類型、不同資料表來源的資料 需要共同排序出現在頁面上

為了整體排序 需要從多張資料表取出資料,合併之後排序 這有效能問題

連資料分頁都不容易

新增資料表來紀錄排序 又有「反正規化」的資料重複出現 data sync 出錯的風險

該如何取捨?如何理解?

https://news.ycombinator.com/item?id=12739632

找到這篇 top comment 描述

From my experience, denormalization of a relational model is a special case of "caching". What you are really doing is caching data where it is most likely to be used at access time. The overview is like this:

1) You need some operation to have low turnaround time / latency

2) So you maintain and update a cache, typically while writing to the data store.

3) Like all caches, you can either invalidate it before changing the data, slightly harming availability, or you can have it lag behind (eventual consistency).

覺得很不錯 將這類設計理解為快取機制即可 應對與注意事項 自然也與面對快取時相同

  分享   共 1,617 次點閱
按了喜歡:
共有 1 則留言
尤川豪   ·  5年前
445 貼文  ·  275 留言

另外附上我在 reddit 的討論串 正反意見都有 果然還是 no silver bullet

https://www.reddit.com/r/SQL/comments/a777qk/is_it_a_bad_idea_if_i_add_some_duplicate_fields/

 
您的留言
尤川豪
445 貼文  ·  275 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章