2022-09-22 存儲引擎不同的索引結構對比

學習資料:

https://shashankbaravani.medium.com/database-storage-engines-under-the-hood-705418dc0e35

https://blog.csdn.net/qq_31807385/article/details/113662819

核心問題:

了解存儲引擎使用的不同的索引結構的特點和場景

存儲引擎分類 日志結構存儲引擎 面向頁面的存儲引擎

1.Hash

基于Hash的索引

無法進行范圍查詢&規(guī)模小 稠密索引 需要很大的內存存放稠密索引

比如Redis

2.SSTables和LSM Tree

基于SSTable的索引

壓縮和合并更快 支持分塊 天生更適合分布式

更好的利用Most Recent原則,多級結構

可以整塊加載到內存進行范圍查詢

更適合寫數(shù)量級高于讀的場景

寫 O(1) 讀 k*O(n) 塊數(shù)*每塊的大小

內存中啥memtable,需要WAL來恢復數(shù)據(jù)

SSTable的合并依賴于塊的大小以及數(shù)據(jù)的age

HBase and Cassandra是經(jīng)典的使用該索引的數(shù)據(jù)結構

3.B-Trees

基于B樹的索引

B-Trees also maintain a sorted in memory map but the underlying file sizes are much smallerblocks of 4KB in line with underlying hardware instead of much larger segments of many MBs.

Thenon leaflevel nodes in the BST contain information around the range of of keys beneath each node. To arrive at a record, we start at therootnode and traverse downwards, breaking down the range at each step ad moving in the direction of the nodes containing the sub-range to which the key belongs.

Theleaflevel nodes either contain the data itself inline or contain references to page blocks which hold the record we are interested in. The number of references to child pages in one page of the B-tree is called thebranching factor(usually in 100s).

B樹的寫需要把整個Block加載到內存,然后整體更新;這導致了讀與寫放大

4.Inverted Index

倒排索引

In search indexes such as ElasticSearch, an index is composed of shards

and each shard is an further broken down into segments. Each segment is

an inverted index in itself and this is how it looks like: a collection

of document Ids and the term frequency.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • 《閉上眼睛才能看清楚自己》這本書是香海禪寺主持賢宗法師的人生體悟,修行心得及講學錄,此書從六個章節(jié)講述了禪修是什么...
    宜均閱讀 10,338評論 1 25
  • 前言 Google Play應用市場對于應用的targetSdkVersion有了更為嚴格的要求。從 2018 年...
    申國駿閱讀 65,971評論 15 98
  • 《來,我們說說孤獨》 1·他們都在寫孤獨 一個詩人 如果 不說說 內心的孤獨 不將孤獨 寫進詩里 是不是很掉價呢 ...
    聽太陽升起閱讀 4,616評論 1 7
  • 自幼貧民窟長大的女子,僥幸多念了兩本書,枉以為可以與人平起平坐。可是人生從來都是接力賽,我們卻天真的當成了百米沖刺...
    Leeanran閱讀 5,914評論 1 5
  • 云舒老師,姓甚名誰,男的女的,多大歲數(shù),這些我全然不知。之所以要寫寫云舒老師,完全是因為他寫的文章,如一個巨大的磁...
    數(shù)豆者m閱讀 2,544評論 6 9

友情鏈接更多精彩內容