MongoDB中大型集合的大容量插入性能 [英] Bulk insert performance in MongoDB for large collections

查看:210
本文介绍了MongoDB中大型集合的大容量插入性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用BulkWriteOperation(Java驱动程序)将数据存储在大块中.乍一看似乎还不错,但是当集合变大时,插入内容可能会花费很多时间.

I'm using the BulkWriteOperation (java driver) to store data in large chunks. At first it seems to be working fine, but when the collection grows in size, the inserts can take quite a lot of time.

当前要收集2000万个文档,批量插入1000个文档可能需要10秒钟.

Currently for a collection of 20M documents, bulk insert of 1000 documents could take about 10 seconds.

有没有一种方法可以使插入物与集合大小无关? 我没有任何更新或更新,它始终是我要插入的新数据.

Is there a way to make inserts independent of collection size? I don't have any updates or upserts, it's always new data I'm inserting.

从日志来看,锁似乎没有任何问题. 每个文档都有一个索引的时间字段,但是它线性增长,因此我认为mongo不需要花时间来重新组织索引.

Judging from the log, there doesn't seem to be any issue with locks. Each document has a time field which is indexed, but it's linearly growing so I don't see any need for mongo to take the time to reorganize the indexes.

我很想听听一些有关改善性能的想法

I'd love to hear some ideas for improving the performance

谢谢

推荐答案

您认为索引不需要任何

You believe that the indexing does not require any document reorganisation and the way you described the index suggests that a right handed index is ok. So, indexing seems to be ruled out as an issue. You could of course - as suggested above - definitively rule this out by dropping the index and re running your bulk writes.

除了索引之外,我还会……

Aside from indexing, I would …

  • Consider whether your disk can keep up with the volume of data you are persisting. More details on this in the Mongo docs
  • Use profiling to understand what’s happening with your writes

这篇关于MongoDB中大型集合的大容量插入性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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