In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Create an index:
Db.t_order_detail.createIndex ({"order_id": 1})
Composite index:
Db.t_order_detail.createIndex ({"order_id": 1, "detail_id": 1, "batch_id": 1})
Create an index in the background:
Db.t_order_detail.createIndex ({order_id:1}, {background:1})
Create a TTL index:
a. After the specified time interval, the collection is invalidated:
Db.t_order_detail.createIndex ({"createTime": 1}, {expireAfterSeconds: 60: 60})-Expiration time (in seconds) is viewed using getIndexes ()
Modify the value of the expireAfterSeconds attribute of the TTL index:
Db.runCommand ({collMod: "t_order_detail", index: {keyPattern: {createTime: 1}, expireAfterSeconds: 7200}})
b. The specified time point expires and the collection expires:
Db.t_order_detail.createIndex ({"expireAt": 1}, {expireAfterSeconds:0})
Db.t_order_detail.insert ({
"createdAt": new Date ('Oct 21, 2018 21 Oct 3000')
"log_Event": 1
"log_Message": "Success!"
})
View the index:
Db.t_order_detail.getIndexes ()
View the index keys:
Db.t_order_detail.getIndexKeys ()
View the total index size of the collection:
Db.t_order_detail.totalIndexSize ()
View the details of each index of the collection:
Db.t_order_detail.getIndexSpecs ()
Delete the index:
Db.t_order_detail.dropIndex ("index_name")
Delete all indexes
The db.t_order_detail.dropIndexes () method is used to delete all indexes
Index rebuild:
Db.t_order_detail.reIndex ({"order_id": 1})
Note:
During the creation of the index in the foreground, the collection will be locked, which will prevent other operations from reading and writing. When the index is created in the background, the write lock will be released periodically to ensure the operation of other operations, but the background operation will take longer, especially on collections that are written frequently.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.