Mongo block uses findOne this returns a document which is not needed to determine if a db is empty instead we can do a find, limit one and hasNext which should be faster.

CommentFileSizeAuthor
#2 mongodb_block_hasnext-2072135-2.patch509 bytesjyee
hasnext.patch538 bytesmarcingy

Comments

marcingy’s picture

Status: Active » Needs review
jyee’s picture

StatusFileSize
new509 bytes

This can be simplified by simply calling find(). Limiting the return to only the _id isn't necessary, since Mongo is only returning the result of hasNext().

fgm’s picture

Issue summary: View changes
Status: Needs review » Fixed

I wasn't sure that it was actually faster, and this is not obvious in the Mongo shell, so I checked and found this blog entry which clearl confirms it:

https://blog.serverdensity.com/checking-if-a-document-exists-mongodb-slo...

Added a comment to specify this and committed to 7.x-1.x, thanks.

  • fgm committed 9751e83 on 7.x-1.x authored by jyee
    Issue #2072135 by marcingy, jyee: Mongo block uses findOne to determine...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.