MongoDB very slow deletes

前端 未结 2 1518
猫巷女王i
猫巷女王i 2021-01-03 01:17

I\'ve got a small replica set of three mongod servers (16GB RAM each, at least 4 CPU cores and real HDDs) and one dedicated arbiter. The replicated data has about 100,000,0

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 01:38

    Another suggestion that may not fit you, but it was optimal solution for me:

    1. drop indeces from collection
    2. iterate over all entries of collection and store id's of records to delete into memory array
    3. each time array is big enough (for me it was 10K records), i removed these records by ids
    4. rebuild indeces

    It is the fastest way, but it requires stopping the system, which was suitable for me.

提交回复
热议问题