zoukankan      html  css  js  c++  java
  • 【MongoDB】The basic operation of Index in MongoDB

    In the past four blogs, we attached importance to the index, including description and comparison with usage of index. Now in this blog, we will mainly focus on the basic operation of index. such query, remove ,repair and so on. 

    1. View Index



    getIndexes could view all the indexes in the collections.


    2. Delete index

     delete all the indexes: db.test.dropIndexes()
     
    delete one index:  db.test.dropIndex({name:1})

    use the command to delete index:

    db.runCommand({dropIndexes:"test",index:{name:1}})



    3. rebuild index

    db.test.reIndex() is equalant to db.runCommand({reIndex:'test'})

    Attention:This operation need to add the lock into the document, so if the collection was filled with a large number of data, this operation would take much time. 

    if using repair to fix database, the database will rebuild the index.
  • 相关阅读:
    图像功率结合
    三星(多星)模型
    双星模型
    卫星变轨问题
    桌面木块弹簧
    球——绳模型、球——杆模型
    汽车拐弯问题
    圆锥摆模型
    省队集训日记
    NOI前比赛经验总结
  • 原文地址:https://www.cnblogs.com/yfceshi/p/7083218.html
Copyright © 2011-2022 走看看