【MongoDB】The basic operation of Index in MongoDB,mongodboperation

來源:互聯網
上載者:User

【MongoDB】The basic operation of Index in MongoDB,mongodboperation

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 indexdb.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.
mongodb中sysindex表是記錄什的?

記錄這個db裡所有的index。
 
David Mytton為何從MySQL遷移到MongoDB資料庫

” 從中感到了作者的歡喜和憂愁,有翻譯不妥或理解不到位的,還請指正:)1,David為什麼要遷移?原文如下:寫道The problem we encountered was administrative. We wanted to scale using replication but found that MySQL had a hard time keeping up, especially with the initial sync. As such, backups became an issue, but we solved that. However, scaling MySQL onto multiple clustered servers as we plan to do in the future is difficult. You either do this through replication but that is only really suited to read-heavy applications; or using MySQL cluster. The cluster looks very good but I have read about some problems with it and was unsure of it’s suitability for our needs.看上去大概的意思是說:我們遇到了管理上的麻煩,雖然我們解決了備份問題。我們試圖通過MySql叢集解決,叢集看上去很好但對於一個大量寫應用來說卻遇到了困難,同時我們也不確定叢集是否適應我們的需求。於是David選擇更換MySQL,選擇了MongoDB。2、為什麼選擇MongonDB?寫道Very easy to install.PHP module available.Very easy replication, including master-master support. In testing this caught up with our live DB very quickly and stayed in sync without difficulty.Automated sharding being developed.Good documentation. 我想最重要的一點應該是:Very easy replication, including master-master support. In testing this caught up with our live DB very quickly and stayed in sync without difficulty. 非常容易的資料拷貝並且快速、一致。3、移植MongonDB後的問題。Schema-less:寫道Schema-lessThis means things are much more flexible for future structure changes but it also means that every row records the field names. We had relatively long, descriptive names in MySQL such as timeAdded or valueCached. For a small number of rows, this extra storage onl......餘下全文>>
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.