[SERVER-27622] Skip document read from disk when delete with IdHack plan Created: 10/Jan/17  Updated: 07/Feb/17  Resolved: 07/Feb/17

Status: Closed
Project: Core Server
Component/s: Performance
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: chensi Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-17148 Remove plans do not need a FETCH stage Backlog
Participants:

 Description   

When delete one record with _id, IdHack stage will read not only the recordId, and the whole record store. Maybe the latter is not necessary.



 Comments   
Comment by David Storch [ 07/Feb/17 ]

Hi hustchensi,

In general, when a document is deleted, it is necessary to read the entire document out of the collection. This is needed to determine which index keys should be deleted, in order to keep all secondary indexes in sync.

However, you are correct that the system is fetching the document twice right now for IDHACK deletes. It does so once in the IDHACK stage:

https://github.com/mongodb/mongo/blob/r3.5.2/src/mongo/db/exec/idhack.cpp#L153

And again for unindexing:

https://github.com/mongodb/mongo/blob/r3.5.2/src/mongo/db/catalog/collection.cpp#L580

SERVER-17148 already tracks the work to get rid of one of these fetches during the execution of delete commands. I'm going to make a note that this also applies to IDHACK deletes. Resolving as a duplicate of SERVER-17148.

Best,
Dave

Generated at Thu Feb 08 04:15:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.