In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
A federated index is used in MongoDB, and some problems are found. Record it for later reference!
First of all, let's look at the description of the table:
Notice the highlighted index:
Prop.lis_sta_1_prop.is_recom_-1_prop.re_t_-1_prop.post_t_-1, these four fields are
Post status, recommendation status, recommendation time, posting time
After a test, the results are as follows
You can use the query indexed above:
Db.post.find ({'prop.lis_sta' {$in [5]}}) .sort ({' prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1}) .explain (); db.post.find ({'prop.lis_sta':5}) .sort ({' prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1}) .explain () Db.post.find ({'prop.lis_sta' {$in [0 prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1 5]}}) .sort ({' prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1}) .limit (20) .explain ()
You cannot use the query indexed above:
Db.post.find ({'prop.lis_sta' {$in [0 prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1 5]}}) .sort ({' prop.is_recom':-1,'prop.re_t':-1,'prop.post_t':-1}) .explain ()
So here are a few points:
1), try to avoid passing sorting rules in the form of flexible parameters, if there is more data, but there is no relevant index, it is easy to cause problems.
2), modified the collation, to check the index, through the explain to test.
3) it is important to filter out as much data as possible and re-sort using existing indexes, while trying to preserve limit restrictions.
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: 245
*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
1. Toolbar tools-> options-> Designer- > uncheck
© 2024 shulou.com SLNews company. All rights reserved.