mongodumpはデータ量が多いときは非常に遅いです

1001 ワード

こちらの解決策は--forceTableScan増加です
--forceTableScan
Forces mongodump to scan the data store directly: typically, mongodump saves entries as they appear in the index of the _id field. Use --forceTableScan to skip the index and scan the data directly. Typically there are two cases where this behavior is preferable to the default:

If you have key sizes over 800 bytes that would not be present in the _id index.
Your database uses a custom _id field.
When you run with --forceTableScan, mongodump does not use $snapshot. As a result, the dump produced by mongodump can reflect the state of the database at many different points in time.


まず、私が使ったのは自分で作ったものです.id.通常、mongodumpはmongoを通過します.idというインデックスを読み取ると、大量のランダムな読み取りが発生します.このパラメータを使用して、_を通過しなくてもいいです.idは読み取りに行きます.
mongodumpのデフォルトではsnapshotが使用され、スキャンされます.idインデックスを作成し、実際のドキュメントを読み取ります.Table Scanはmongodbの物理記憶順にスキャンされ、indexを読み込むプロセスはありません.しかしtablescanの潜在的な問題は、1つのドキュメントがdump中に移動した場合(物理的に)、最終的に2回出力される可能性があることです.