bayer
bayer

Reputation: 6904

MongoDB takes long for indexing

I have the following setup:

Calling .ensureIndex(...) takes more than an hour, actually I killed the process after that. My impression is, that it takes far too long. Also, I terminated the process but the index can be seen with .getIndexes() afterwards.

Anybody knows what is going wrong here?

Upvotes: 2

Views: 1827

Answers (2)

flindeberg
flindeberg

Reputation: 5027

I would just like to point out the command:

db.currentOp()

which prints the current operations running on the server, and also shows the indexing process.

The foreground indexing is done in 3 steps, and the background one in 2 steps (if I remember correctly), but the background one is alot slower. The foreground one on the other hand locks the collection while indexing it (ie not very useful on a running application server).

As said before, google BTree if you are interested in how they work.

Anybody knows what is going wrong here?

Are you running via ssh or connecting remotely in some way? Sound a bit like a broken pipe issue. Did you create the index with {background : true} or not?

Upvotes: 0

mdirolf
mdirolf

Reputation: 7651

Adding an index on an existing data set is expected to take a while, as the entire BTree needs to be constructed. If you think this is taking an unreasonable amount of time, or you've seen a regression in performance the best bet is to ask about it on the list.

Upvotes: 2

Related Questions