Imagine you have the following situation:
for i in xrange(100000):
account = Account()
account.foo = i
account.save
Obviously, the 100,000 INSERT
statements executed by Django are going to take some time. It would be nicer to be able to combine all those INSERT
s into one big INSERT
. Here's the kind of thing I'm hoping I can do:
inserts = []
for i in xrange(100000):
account = Account()
account.foo = i
inserts.append(account.insert_sql)
sql = 'INSERT INTO whatever... ' + ', '.join(inserts)
Is there a way to do this using QuerySet, without manually generating all those INSERT
statements?