开发者

Can I index system.namespaces in MongoDB?

I want to be able to do fast prefix searches over system.namespaces in my database which will have a huge number of collections. Is it okay to index system.namespaces? The Mongo docs seem to vaguely suggest not messing with system.namespaces.

Update: I am doin开发者_如何学Gog the search directly, a call like

db.system.namespaces.find({"name":/^some_prefix/})


So first, if you're planning to run lots of collections, ensure that you've expanded the size of your namespaces file.

Is it okay to index system.namespaces?

This collection is actually hidden by default. It exists, but it won't appear when you use a show collections or equivalent. It sounds like you want to optimize the collection for queries on collection names, but I'm not 100% sure this is actually the mechanism used.

The data in the .ns files contain data about each collection and I'd expect that this data is basically held in memory. So I'm not sure that optimizing system.namespaces will do anything unless you can confirm that it's actually being used on your specific queries.

The exact answer to this question is probably known by about 5 people and they all work at 10gen :) Your best bet for a precise answer is to check the Google Groups or the code itself. The 10gen staff monitor the groups and you may get the actual authors to answer your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜