In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This series of articles translated from "50 Tips and Tricks for MongoDB Developers", temporarily did not find the Chinese version, anyway, I have recently been in-depth study of mongodb, so just take it to translate. On the one hand, strengthen the effect of your own learning, on the other hand, let everyone experience what we mongodb users need to pay attention to.
First of all, I declare that my English level is not too high. In addition, some English translations into Chinese cannot find suitable words to express them. Therefore, English original words may appear in the article, or translation in some places will be somewhat rigid, that is to say, literal translations will appear. The main purpose of translating this book is for everyone to study and discuss. If there is any inaccurate translation, or if there is a more accurate translation, please point out that I will correct it in time. Thank you in advance.
Tip#23.Don't always use an index
Don't always use indexes
I talked about the benefits of using indexes earlier, but let me remind you that not all queries should use indexes. Suppose, in the previous example, that you get 90% of the documents in the collection, not just a small portion. If we still use indexes in this case, we will have to query almost all indexes. That is to say, 60G indexes will be loaded into memory, and 230G documents will be loaded into memory according to the pointers of the indexes. A total of 60G+230G=290G of data needs to be loaded into memory, which greatly exceeds the case without indexing.
Therefore, indexes are usually useful when you are querying only a small portion of the data. As a rule of thumb, once you have returned more than half the data, don't use the index.
If you index a field, but require a large amount of data to be returned, it is inefficient. At this point you can tell mongodb not to use indexes for this query by specifying {"$natural":1} in sort. This means that the data will be returned sequentially from disk, forcing mongodb not to use indexes.
>db.foo.find().sort({"$natural":1})
If a query forces no index, mongodb scans the table, meaning it finds documents that match the criteria by comparing all records.
Each time a new record is added, deleted, or updated, the index is updated. Suppose you add a record, mongodb or query where the value of the new node needs to fall in the index tree, and then insert the index. For deletion, you also need to find and delete the index, and the same process is required for updating the value. So indexes add extra work to write operations.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.