欢迎投稿

今日深度:

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

【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 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.

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......余下全文>>
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/4077.html NewsArticle 【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 bas...
评论暂时关闭