⬅︎ Back to Simple or fancy UPSERT in PostgreSQL with Django
Hey Peter,a better approach for the orm would be to first update, `updated = Model.objects.filter(...).update(..)`And insert only of no rows were updated`if updated == 0: # insert`The comparison between the two approachs depends on wheather you have more updates or inserts.
Worth a thought. I should re-run my little benchmark if I have near 100% updates done.
Comment
Hey Peter,
a better approach for the orm would be to first update,
`updated = Model.objects.filter(...).update(..)`
And insert only of no rows were updated
`if updated == 0: # insert`
The comparison between the two approachs depends on wheather you have more updates or inserts.
Replies
Worth a thought. I should re-run my little benchmark if I have near 100% updates done.