I have a for loop that goes through millions of objects. What would be the suggested way to commit this? Here are a few examples I was thinking of:
# after each
for item in items:
cursor.execute()
conn.commit()
# at the end
for item in items:
cursor.execute()
conn.commit()
# after N items
for n, item in enumerate(items):
cursor.execute()
if n % N == 0:
conn.commit()
conn.commit()
Which of the above would be the most efficient?