In MongoEngine version 0.8.7, For every document insert, Its rebuilding all indexed defined in meta attribute. Following is code snippet to replicate the issue.
from mongoengine import connect
from mongoengine import DynamicDocument
from mongoengine import Document
from mongoengine.connection import get_db
from mongoengine import *
conn = connect( 'test',
host=''
)
class Test(Document):
meta = {
'indexes': [
{
'fields': ['value']
},
{
'fields': ['#customer']
},
{
'fields': ['#_id']
}
]
}
name = StringField()
value = StringField()
customer = StringField()
if __name__ == '__main__':
for num in range(1,20):
ross = Test(name= str(num), value =str(num), customer = "customer" + str(num))
obj = ross.save()
When first document inserted, all indexes would be created and in place. In my case, mongo server is rebuilding these three indexes for each document I insert( 20 times in above example ) . These cause severe impact on server performance.