1. 程式人生 > >mongodb 的 mmap 和wiredtiger 引擎對比.實現對比

mongodb 的 mmap 和wiredtiger 引擎對比.實現對比

mongodb mmap引擎檔案頁管理交由作業系統 mmap 來管理.

https://www.quora.com/How-is-a-read-query-processed-in-MongoDB

How is a read query processed in MongoDB? Does it work  like RDBMS ? for example   In mysql , query performance work at three main points
                                       Buffer pool
                                       block size
                                       Indexes
In MongoDb i saw only Indexes , But i am not able to find how mongoDB work with two cases (Bufferpool and Block) .Would  any body please provide me links where  i find  how mongodb work for read and write ?

答:

In v3.0+, storage engines are pluggable, so the answer will depend on the storage engine.

With the legacy mmap storage engine, the first two things you mentions are auto-configured / implied by the virtual memory manager because of the use of mmap, so you don't have to specify anything there.
(phil 前兩項都是由作業系統管理. 說明 mmap 引擎的索引保持的是檔案的 offset .不然還得重新查詢到 offset . 這個又 mysql 的 myisam 有點像. 不然就需要既要維護 mmap,又要維護 內容 page的儲存結構, 用來 快速查詢 id 對應的 offset )

 innodb自己維護 pool ,作業系統維護 pool 的好處. 當然每個 page 快取可能是跳過核心態的

As another example, you can find the configuration settings for the WildTiger storage engine here:.
Regardless of storage engine there are indexes and conceptually this is similar to other databases.

WildTiger可以選擇 btree 搜尋和 lsm 索引

https://raw.githubusercontent.com/wiki/wiredtiger/wiredtiger/attachments/LSM_btree_Throughput.png

結論:  wiredtiger 在 寫併發(寫鎖佔用)和記憶體佔用上都遠遠優於了 mmap . rocket mq 最初也是用 mmap,當記憶體不夠用時, 就會出現卡頓的現象.  原因?

https://stackoverflow.com/questions/37985134/how-to-choose-from-mmapv1-wiredtiger-or-in-memory-storageengine-for-mongodb