Is there any performance benefit to using bulk_update as compared to just update in django for a same value update?

I have the following piece of code

Subscription.objects.filter(id__in=[ for subscription in subscriptions]).update(renewal_notification_sent=True)

but I'm wondering if something like

updatable_subscriptions = []
subs = Subscription.objects.filter(id__in=[ for subscription in subscriptions])
for sub in subs:
    sub.renewal_notification_sent = True


# then
Subscription.objects.bulk_update(updatable_subscriptions, ["renewal_notification_sent"])

would have any performance benefit. Does calling filter followed by update make 2 database queries?

filter followed by update make 2 queries. About performance, bulk_update does an sql update with case while update does a simple update behind the scenes, for bigger updates it's better use bulk_update.

Back to Top