# took 72 seconds
def auto_transaction():
for record in Record.objects.all():
record.name = "String without number"
record.save()
# took 17 seconds
@transaction.commit_manually
def manual_transaction():
for record in Record.objects.all():
record.name = "String without number"
record.save()
transaction.commit()
# took 0.03 seconds
def builtin():
Record.objects.all().update(name="String without number");
# took 37 seconds
def auto_transaction():
for i in range(10000):
name="String number %s" %i
Record.objects.create(name=name)
# took 2.65 seconds
@transaction.commit_manually
def manual_transaction():
for i in range(10000):
name="String number %s" %i
Record.objects.create(name=name)
transaction.commit()
# took 0.47 seconds
def builtin():
insert_list = []
for i in range(10000):
name="String number %s" %i
insert_list.append(Record(name=name))
Record.objects.bulk_create(insert_list)