TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

MongoMem: Memory usage by collection in MongoDB

33 pointsby rgarciaabout 11 years ago

2 comments

fiatmoneyabout 11 years ago
Mongo&#x27;s internal storage mechanisms are a mess. BSON is incredibly inefficient as a storage format (for instance, it stores arrays as string -&gt; string maps with a literal index, ie [&quot;1&quot; &quot;first element&quot; &quot;2&quot; &quot;second element&quot;]), it relies on mmap &#x2F; fsync for read &#x2F; write scheduling (see [1] for some issues specifically with regards to database usage), and its &quot;linked list of documents&quot; approach means that any appreciable number of removals or updates badly fragments your storage space. Oh, and key names aren&#x27;t interned, so better use the first N unicode characters rather than sensible names if you need to fit everything into the page cache (and due to the lack of caching algorithms beyond the OS&#x27;s LRU-by-page, you definitely need to fit everything into the page cache). &quot;Everything&quot; really means &quot;both data <i>and indexes</i>&quot; since the OS doesn&#x27;t know the difference between your index &amp; data - it will quite happily evict index entries from cache in favor of a data scan.<p>[1] <a href="http://rhaas.blogspot.co.uk/2014/03/linuxs-fsync-woes-are-getting-some.html" rel="nofollow">http:&#x2F;&#x2F;rhaas.blogspot.co.uk&#x2F;2014&#x2F;03&#x2F;linuxs-fsync-woes-are-ge...</a>
评论 #7699154 未加载
评论 #7695839 未加载
caio1982about 11 years ago
I&#x27;m so going to use it. Thanks for open sourcing it!
评论 #7699487 未加载