In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 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.
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.