为什么MongoDB占用了这么多的空间? [英] Why does MongoDB takes up so much space?

查看:289
本文介绍了为什么MongoDB占用了这么多的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在mongoDB中存储一组双打和整数(大约15-20)的记录。大多数(99.99%)的记录具有相同的结构。

I am trying to store records with a set of doubles and ints (around 15-20) in mongoDB. The records mostly (99.99%) have the same structure.

当我将数据存储在 root 这是一种非常结构化的数据存储格式,该文件在 2.5GB / strong>记录。然而,对于Mongo,数据库大小(来自命令 show dbs )大约是 21GB ,而数据大小( db.collection.stats())位于 13GB 左右。

When I store the data in a root which is a very structured data storing format, the file is around 2.5GB for 22.5 Million records. For Mongo, however, the database size (from command show dbs) is around 21GB, whereas the data size (from db.collection.stats()) is around 13GB.

这是一个巨大的开销( Clarify:13GB vs 2.5GB,我甚至不谈论21GB ),我猜是因为它存储。所以问题是,为什么和如何 Mongo 不能做更好的工作,使其更小?

This is a huge overhead (Clarify: 13GB vs 2.5GB, I'm not even talking about the 21GB), and I guess it is because it stores both keys and values. So the question is, why and how Mongo doesn't do a better job in making it smaller?

但主要的问题是,在这方面的性能影响是什么?我有4个索引,他们出来是 3GB ,所以运行在单个8GB机器上的服务器可以成为一个问题,如果我加倍的数据量,并尝试保持一个大的工作集在内存中。

But the main question is, what is the performance impact in this? I have 4 indexes and they come out to be 3GB, so running the server on a single 8GB machine can become a problem if I double the amount of data and try to keep a large working set in memory.

任何猜测,如果我应该使用SQL或其他数据库?

Any guesses into if I should be using SQL or some other DB? or maybe just keep working with ROOT files if anyone has tried them?

推荐答案

基本上,这是mongo准备插入数据。 Mongo对数据执行预存储存储,以防止(或最小化)磁盘上的碎片。这个预定义是以 mongod 实例创建的文件的形式来观察的。

Basically, this is mongo preparing for the insertion of data. Mongo performs prealocation of storage for data to prevent (or minimize) fragmentation on the disk. This prealocation is observed in the form of a file that the mongod instance creates.

首先它创建一个64MB的文件,下一个128MB,下一个512MB,以及on和on,直到它达到2GB(预先分配的数据文件的最大大小)的文件。

First it creates a 64MB file, next 128MB, next 512MB, and on and on until it reaches files of 2GB (the maximum size of prealocated data files).

mongo还有一些东西可能会出现使用更多磁盘空间的情况,例如日记 ...

There are some more things that mongo does that might be suspect to using more disk space, things like journaling...

有关mongoDB如何使用存储空间的更多信息,您可以查看此页面,特别是

For much, much more info on how mongoDB uses storage space, you can take a look at this page and in specific the section titled Why are the files in my data directory larger than the data in my database?

有一些事情你可以做,以尽量减少使用的空间,但这些tequniques(如使用 - smallfiles 选项)通常只推荐用于开发和测试用途 - 从不用于生产。

There are some things that you can do to minimize the space that is used, but these tequniques (such as using the --smallfiles option) are usually only recommended for development and testing use - never for production.

这篇关于为什么MongoDB占用了这么多的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆