MongoDB Replica Set secondary Initialization Synchronization Data Problem

  mongodb, question


Due to insufficient disk space, to replace the hard disk where mongoDB's working directory is located,
 Among them, there is a db of data about 150G in size, and now there is a new hard disk.
 After the synchronization of the new node initialization from the primary node is completed, the size of the db is only about 70G.
 The total count of each collection in the bottom has not changed.


After this synchronization, why does the data capacity differ so much?
 Is there data compression or something in this full-scale initialization synchronization method?
 After reading the documents, I haven't found any relevant information for a long time.  Kneel down!  !  !

Because some data has been deleted. Things like databases do not automatically reduce the file size when data is deleted-because this is an extremely expensive operation that requires rewriting the entire file.

However, it’s okay. Although MongoDB is not PostgreSQL and there is no automatic collation, MongoDB is not MySQL, and even manual collation is impossible. You try the compact command, if you can’t, try repair. I have done it before, but now I forget it.