Skip to content

Instantly share code, notes, and snippets.

@stephencweiss
Last active November 24, 2018 22:28
Show Gist options
  • Save stephencweiss/1feb3d3fba6fef47590c8c3ab7efd47d to your computer and use it in GitHub Desktop.
Save stephencweiss/1feb3d3fba6fef47590c8c3ab7efd47d to your computer and use it in GitHub Desktop.
db.descriptions.find( { productId: 1928222 } )
db.descriptions.find( { productId: { $gt : 9999990 } } )
@stephencweiss
Copy link
Author

image
image

@stephencweiss
Copy link
Author

Because the productId field has been indexed, Mongo is able to go directly to the record and retrieve it. This is evident by the fact that only 1 document was examined in the specific ID lookup and 10 in the $gt lookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment