1 | | I noticed that loading many fixtures is fairly inefficient, in that it tries an update and then an insert for each record. I would propose an additional option to the command line (—bulk-insert) that only runs the insert queries, but also detects if subsequent items in the fixtures are from the same model, so they may be inserted using bulk_insert. If there is genuine interest in this feature i will develop it and submit. I have this running in my own codebase already. |
2 | | Please also indicate if there is no interest, and i spend my energy elsewhere =) |
| 1 | As per this forum discussion, I have created a patch to improve load times for the loaddata command under some circumstances. |
| 2 | |
| 3 | Currently the “loaddata” management command uses the obj.save() method for each deserialized object within a fixture. This function first tries an UPDATE statement and, if that fails, tries an INSERT statement. By using the --force_insert a reduction of 50% of queries is achieved. |
| 4 | |
| 5 | A second option is to use bulk_create for insertion of multiple records. This improves insertion speed by (n-1/n), or ~99% for insertion of 100 records. |
| 6 | |
| 7 | These options are not meant to cover each use case, and therefore are set to optional. |
| 8 | |
| 9 | |
| 10 | |