- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个名为 log_test1 的数据库,只有 1 个上限收集日志。上限集合的最大大小为 512M。插入200k数据后,发现db的磁盘使用量为1.6G。使用 db.stats(),我可以看到 storageSize 是 512M,正确,但我实际的 fileSize 是 1.6G,为什么会这样?如何控制磁盘大小只是我的上限集合大小加上索引大小?
> use log_test1
switched to db log_test1
> db.stats()
{
"db" : "log_test1",
"collections" : 3,
"objects" : 200018,
"avgObjSize" : 615.8577328040476,
"dataSize" : 123182632,
"storageSize" : 512008192,
"numExtents" : 3,
"indexes" : 8,
"indexSize" : 71907920,
"fileSize" : 1610612736,
"nsSizeMB" : 16,
"dataFileVersion" : {
"major" : 4,
"minor" : 5
},
"ok" : 1
}
最佳答案
这可能是因为 MongoDB 预先分配了数据和日志文件。
MongoDB 2
In the data directory, MongoDB preallocates data files to a particular size, in part to prevent file system fragmentation. MongoDB names the first data file
<databasename>.0
, the next<databasename>.1
, etc. The first file mongod allocates is 64 megabytes, the next 128 megabytes, and so on, up to 2 gigabytes, at which point all subsequent files are 2 gigabytes. The data files include files with allocated space but that hold no data. mongod may allocate a 1 gigabyte data file that may be 90% empty. For most larger databases, unused allocated space is small compared to the database.On Unix-like systems, mongod preallocates an additional data file and initializes the disk space to 0. Preallocating data files in the background prevents significant delays when a new database file is next allocated.
You can disable preallocation with the noprealloc run time option. However noprealloc is not intended for use in production environments: only use noprealloc for testing and with small data sets where you frequently drop databases.
MongoDB 3
The data files in your data directory, which is the
/data/db
directory in default configurations, might be larger than the data set inserted into the database. Consider the following possible causes:Preallocated data files
MongoDB preallocates its data files to avoid filesystem fragmentation, and because of this, the size of these files do not necessarily reflect the size of your data.
The
storage.mmapv1.smallFiles
option will reduce the size of these files, which may be useful if you have many small databases on disk.The oplog
If this mongod is a member of a replica set, the data directory includes the
oplog.rs
file, which is a preallocated capped collection in the local database.The default allocation is approximately 5% of disk space on 64-bit installations.
The journal
The data directory contains the journal files, which store write operations on disk before MongoDB applies them to databases.
Empty records
MongoDB maintains lists of empty records in data files as it deletes documents and collections. MongoDB can reuse this space, but will not, by default, return this space to the operating system.
取自 MongoDB Storage FAQ .
关于mongodb - 为什么我的 mongodb fileSize 比 db.stats() 中的 storageSize 大得多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20533419/
我有一个包含 .tcb 和 .tch 文件的文件夹。我需要知道所有 .tcb 文件的大小,分别是所有 .tch 文件的大小。 我确实喜欢这样: 1)我创建了一个临时文件夹,然后: mv *tch te
如果分辨率大于 256x256,有没有办法将图像转换为 ICO 格式? 我找到了几个程序,但没有一个能够转换更大的图像。我需要的尺寸是 1024x1024。 最佳答案 由于宽度和高度在 ICO 图像格
我正在尝试通过 PHP 上传图像。上传时,它应该调整大小,使其尺寸与我在配置 [] 数组中定义的一样大,并且其文件大小也小于或等于我的配置 [] 数组中的预定义值。但不知何故,方法 getFileSi
关于获取文件的大小,我有这两个函数: function GetFileSize1(const FileName: TFileName): Int64; var iTmp: Int64; Searc
我正在尝试使用system.filesize函数来获取delphi中文件的大小,它对于4GB的文件则失败。所以我实现了自己的,将所需的文件作为文件流打开,并获取完美运行的流大小。 这是一个片段
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: PHP – get the size of a directory 我在一个目录中有 5 个文件,它显示文件
好的, 我使用此函数来获取程序中的文件大小,即使对于 4GB 以上的文件,它也能很好地工作。 function FileSize(const PathtoFile: string): Int64; v
我在 JS 中有这个预加载图像的功能: // http://stackoverflow.com/questions/3646036/javascript-preloading-images var p
错误: Warning: filesize() [function.filesize]: stat failed for http://website.com/wp-content/uploads/2
当我运行这段代码时: 我得到结果 10,这是文件中正确的字符数。 但是,由于文件系统 block 比这大得多,我希望文件大小“四舍五入”到更接近 512 字节甚至 1KB。为什么不是? 最佳答案 不
除 IE 之外的任何浏览器是否支持 document.file Size 或同等大小? http://msdn.microsoft.com/en-us/library/ms533752(v=VS.85
我正在编写一个 PHP 页面,它通过抓取现有的 HTML 页面来生成播客提要。一切正常,但我的一个 mp3 文件出现“filesize(): stat failed”错误。据我所知,该文件没有损坏,并
$path = "/////////."; echo filesize( $path ); 结果是 4096 这是什么……失败了? 4096 是从哪里来的? 最佳答案 回答: $path = "///
我注意到当我尝试使用如下路径列出目录的内容时,filesize 不起作用: ../ 例如这个有效: if ($handle = opendir('./')) { while (false !=
我注意到当我尝试使用如下路径列出目录的内容时,filesize 不起作用: ../ 例如这个有效: if ($handle = opendir('./')) { while (false !=
我想在此脚本中显示 1MB 错误消息而不是 1024: http://jsfiddle.net/tyaenm09/37/ 使用带有文件大小扩展名的 jquery-validation 插件。当然,我可
我想为 FTP 下载创建一个进度条。我下载文件的服务器隐藏了所有目录和文件。我想显示下载进度。有什么办法可以获得文件大小吗?这是我当前的代码: FTPclient = new FTPClient
这个问题在这里已经有了答案: Why does integer division in C# return an integer and not a float? (8 个答案) Division
我一直在苦苦思索如何在 PHP 中获取大于等于 2 GB 的文件的有效文件大小。 例子 在这里,我使用 filesize() 函数检查一个 3,827,394,560 字节大的文件的文件大小: ech
代码: var upload = multer({dest:"./uploads"}); app.post("/", upload.single("file"), function (req, res
我是一名优秀的程序员,十分优秀!