下面以创建10000个对象为例进行测试:#用for循环挨个创建,共花费37秒foriinrange(10000):name="Stringnumber%s"%iRecord.objects.create(name=name)#用django事务只提交一次,共花费2.65秒@transaction.commit_manuallydefmanual_transaction():foriinrange(10000):name="Stringnumber%s"%iRecord.objects.create(name=name)transaction.commit()#用bulk_create创建,共花费0.47秒defbuilt...
继续阅读 >