I just had an interesting experience with the mongoexport tool and came out with a doubt about the exporting process' disk usage.
I was trying to dump a 50 MB collection to a disk that had 3 GB free disk space. When the dump reached 101 records, it halted and eventually the connection timed out. You can read more about it here.
User @priyanka-kariya suggested I checked disk space, then I freed a total of 13 GB and the dump ran ok again.
So I wondered, how is disk space used in order to complete a dump process?
*Both mongoexport and mongod are version 4.0.2.
EDIT
@Stennie suggested I checked uncompressed data size, so db.requests_PRD.stats()
returns:
{
"ns" : "bubeIO.requests_PRD",
"size" : 52721003,
"count" : 60196,
"avgObjSize" : 875,
"storageSize" : 15486976,
"capped" : false,
[...]
}
The size is actually 50.3 MiB, which is less than I initially thought.
mongoexport
is just doing a normalfind
query, so the behaviour I mention above is the standard expectation for cursor batches. If you want to peek at the actual logic, themongoexport
source (in Go) is available on GitHub. – Stennie Feb 12 '19 at 9:34