Updated on 2022-06-21 GMT+08:00

Write/Update

  • Operations such as write, update, delete,and index insert and delete are actually converted to write operations in the background. The underlying storage engines (WiredTiger and RocksDB) use the appendOnly mechanism. Only when the internal data status of the storage engine meets certain conditions, the internal compaction operation is triggered to compress data and release disk space. That is why sometimes the disk usage seems greater than the actual data volume, but your services are not affected.
  • The write/update operation involves synchronization to the standby node. You can specify the writeConcern level for the operation. For details, see Write Concern.

Precaution

  • update and upsert: If you use upsert, the data you want to insert will be queried first. If the data does not exist, it will be inserted. Otherwise, an update operation is performed. In the preceding scenario, the update or insert command is recommended.
  • The update operation also needs to match the index.
    • Do not use COLLSCAN to scan the entire table.
    • Query conditions and index fields are matched in sequence.
  • The size of the document involved in the insert or update command cannot exceed 16 MB.