MongoDB索引在重新启动后是否持久化? [英] Are MongoDB indexes persistent across restarts?

查看:150
本文介绍了MongoDB索引在重新启动后是否持久化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处参考该指南, http://docs.mongodb.org/manual/core/indexs/我无法确定字段的Mongo索引是否持久存储.

Referencing the guide here, http://docs.mongodb.org/manual/core/indexes/ I cannot tell if Mongo indexes for fields are stored persistently.

如果在使用MongoDB的应用程序中调用(并完成了)ensureIndex(),则在以下情况下会发生什么:

If ensureIndex() is called (and completes) within an application using MongoDB, what happens if:

  1. 使用MongoDB的应用程序将重新启动.后续对ensureIndex()的调用会导致完全重新索引吗?
  2. MongoDB服务器已重新启动.以后从客户端应用程序调用ensureIndex()会重新构建吗?
  3. 是否有多个客户端会话会影响其中的任何一个?我假设每个文档的索引在整个集合中都是全局的:"MongoDB defines indexes on a per-collection level."
  1. The application using MongoDB is restarted. Will a subsequent call to ensureIndex() cause a complete reindex?
  2. The MongoDB server is restarted. Would a later call of ensureIndex() from a client application rebuild?
  3. Is any of this affected by having multiple client sessions? I assume indexing is global across the entire collection per the documentation: "MongoDB defines indexes on a per-collection level."

推荐答案

使用MongoDB的应用程序将重新启动.随后的对sureIndex()的调用会导致完整的重新索引吗?

The application using MongoDB is restarted. Will a subsequent call to ensureIndex() cause a complete reindex?

否,因为索引已经存在,它应该(与其他驱动程序一样)注册为no op.一些驱动程序提供了一种缓存机制,无需进入服务器即可检测是否已创建索引(即Python).

No, it should (as in every other driver) register as a no op since the index already exists. Some drivers provide a cache mechanism to detect, without going to the server, if an index has been created (i.e. Python).

MongoDB服务器重新启动.客户端应用程序中稍后的sureIndex()调用会重新生成吗?

The MongoDB server is restarted. Would a later call of ensureIndex() from a client application rebuild?

与上述相同

是否有多个客户端会话会影响其中的任何一个?我假设每个文档的索引在整个集合中都是全局的:"MongoDB在每个集合级别定义索引."

Is any of this affected by having multiple client sessions? I assume indexing is global across the entire collection per the documentation: "MongoDB defines indexes on a per-collection level."

是的,索引存储在集合本身的MongoDB中(从技术角度来说,作为db.ns文件中的命名空间).由于它是ensureIndex的单一知识点,而索引是一个单独的进程(与写锁确实非常相似),因此多个连接不应影响索引创建是否被注册两次.

Yes indexes are stored in MongoDB on the collection itself (to be technical, as a namespace within the db.ns file). Since it is a single point of knowledge for ensureIndex and an index is a single process (much like the write lock really) multiple connections should not effect whether the index creation is registered twice.

这篇关于MongoDB索引在重新启动后是否持久化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆