Repeated build index on insert operation

18 views
Skip to first unread message

VISHAL KUMAWAT

unread,
Nov 29, 2016, 1:39:14 AM11/29/16
to MongoEngine Developers
Hi,

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. 

Regards,
Vishal

Andrew Maizels

unread,
Nov 29, 2016, 3:00:50 AM11/29/16
to mongoen...@googlegroups.com
I don't know why it's doing that, but you can set a flag to stop automatic index creation:

meta = {
    'auto_create_index': False,
    ....

--

---
You received this message because you are subscribed to the Google Groups "MongoEngine Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoengine-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ahh... We are all heroes; you and Boo and I.
Hamsters and rangers everywhere, rejoice!
Read Peopleware! http://www.amazon.com/Peopleware-Productive-Projects-Teams-Second/dp/0932633439
Reply all
Reply to author
Forward
0 new messages