[MongoDB] MongoDB's missing knowledge points and mongodb's missing knowledge points
Up to now, I have read three mongodb books. Today, when I read the MongoDB authoritative guide by Kristina Chodorow in the United States, I found that there are still many omissions in my knowledge. Now I want to make a supplement;
I. Deletion speed
Deleting a document is usually fast, but it is slow to clear the entire set. Using drop to directly Delete the set is faster;
Now we have created more than 10 million test records:
Use db. tester. drop () instead of remove and findone, the speed is improved but there is a cost. No query conditions can be specified. The entire set is deleted, and all metadata is lost. After removing, the indexes remain unchanged;
2. Return array elements
If you know the subscript of an element, "$ slice" is very useful. But sometimes we want to return any array element that matches the query condition. Initialize a record to describe slice usage: