Hi Erik,

In the actually code I create and preload all the DataPoints and Sensors 
outside the loop.  I found a dict was too slow for DataPoints.  I ended up 
sorting the DataPoints query by date and using the fact that they were in 
the same order as the CSV to speed things up.  

Looping through the datapoinst and the dp.Sensors.add line is too slow.  

Can you explain what you mean by “If you need better bulk-insert 
performance than this, you can convert the m2m relation between Sensor and 
DataPoint to an explicit m2m model. You can then bulk-insert all m2m 
relations in one go instead of per-object”?   I’m not sure how to implement 
this.  

Here is what the data will look like
time  sensorA  sensorB
_______________________
1      4        5
2      6        4
3      9        2
4      3        7

The problem is that I'm calling DataPoint.add at lot.  It seems like there 
should be a more efficient want to add them instead of looping though each 
datapoint and calling .add.  I'd like to do something like bulk_create.    

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a08acbf0-6758-4187-89fc-f0c1f07a6a3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to