A potential argument *against* using indexes in MongoKit

269 views
Skip to first unread message

Peter Bengtsson

unread,
Mar 23, 2011, 8:19:20 PM3/23/11
to mong...@googlegroups.com
First of all, I went to a presentation on indexing recently at MongoUK by Richard K who pointed out that `ensureIndex` should not be taken lightly. Just because it's called "ensure" doesn't mean it might not necessarily re-index everything. And that can potentially be very expensive if the indexes grow large. He also said, to treat creating indexes (with `ensureIndex()`) as an administrative task rather than a development task.

I don't feel confident that MongoKit won't wrongfully execute `ensureIndex()`. In fact, I don't even understand when it does execute it if defined as attributes on a Document class.

Thoughts?


Nicolas Clairon

unread,
Mar 24, 2011, 10:24:42 AM3/24/11
to mong...@googlegroups.com
I went to that conclusion too. Indexes should be created with care
directly on the collection.

I shall remove the indexes feature in the 0.8 version. I fired a ticket here :

https://github.com/namlook/mongokit/issues/44

N.

Allan Caffee

unread,
Mar 25, 2011, 9:42:43 AM3/25/11
to MongoKit


On Mar 24, 10:24 am, Nicolas Clairon <clai...@gmail.com> wrote:
> I went to that conclusion too. Indexes should be created with care
> directly on the collection.
>
> I shall remove the indexes feature in the 0.8 version. I fired a ticket here :
>
> https://github.com/namlook/mongokit/issues/44
>
> N.

Do you intend to remove the functionality of creating and specifying
indexes altogether? It seems like it would be preferable to leave the
implementation in place and have the indexes not be enforced by
default. This would allow developers to write simple administrative
code which could be used to ensure the existence of indexes without
having potentially negative consequences for code running in
production.

I find the validation of indexes to be a useful feature in MongoKit,
and it is convenient to keep the index declarations in the same place
as the document structure and the queries using the data.

--
Allan

Nicolas Clairon

unread,
Mar 25, 2011, 10:32:13 AM3/25/11
to mong...@googlegroups.com, Allan Caffee
yes, it will be done elegantly, with warning at runtime during the
development versions (0.7.x branch).

I think a best practice is to have a script like "ensure_indexes.py"
(maintain by the developper) which create all indexes separately.

But I will leave the validation feature, remove the automatique index
creation and add an `ensure_index` method with options (like
background).

Reply all
Reply to author
Forward
0 new messages