The call to `getKeys` in `IndexAccessMethod::findSingle` is very costly, causing a 2-5% reduction in the humber of ops per second for simple update queries.
To test this, I ran microbenchmarks comparing a recent master commit (b4d550) to the same code but without the call to `getKeys`, yielding the following results:
Storage Engine | # threads | increase in ops/second |
---|---|---|
mmapv1 | 1 | 2.07% |
mmapv1 | 2 | 3.68% |
mmapv1 | 4 | 5,10% |
mmapv1 | 8 | 5,70% |
wiredTiger | 1 | 2.38% |
wiredTiger | 2 | 2.82% |
wiredTiger | 4 | 2.30% |
wiredTiger | 8 | 3.07% |
Simply removing the call will not suffice, as it is needed for when there are non-default collations on the _id field. geert.bosch suggested that implementing a cheap way to check if there is a non-default collation on the _id (possible by either adding a boolean field somewhere that keeps track fo this or by iterating over the indexes to check) would make it possible to avoid the call in the cases where it isn't necessary.