fopina / django-bulk-update-or-create

`bulk_update_or_create` for Django model managers
MIT License
148 stars 16 forks source link

Performance #30

Closed PetrDlouhy closed 2 years ago

PetrDlouhy commented 2 years ago

I tried to use this, but I find the performance very insuficient for my case. I want to cache chart values in django-admin-charts, but if I cache daily values for a few years, this bulk update will run for tens of seconds. In comparison Django's bulk_create runs only about a second.

So in my case I found it better to delete all the old values and create the new ones with bulk_create.

fopina commented 2 years ago

Thanks for the feedback. Not entirely sure what is the ask though as not familiar with that package nor what calls you doing.

if calling delete and bulk_create is an option for you, it should be faster indeed.

this is meant to “update” and I guess that comes at a cost.

fopina commented 2 years ago

Closing for lack of details

PetrDlouhy commented 2 years ago

I just wanted to point out, that there are big reserves in performance over bulk_create and that users should know, that in some cases there are quicker ways to go.

fopina commented 2 years ago

Indeed, thanks for that. Though not sure how that would fit in the docs as this is for “update_or_create” which “delete and create” is definitely not the same (triggers, cascade deletions, auto PK changes, etc)

PetrDlouhy commented 2 years ago

You are absolutely right. I don't have to care much about any of this, because I am not working with primary data. And the performance is the primary concern for this case.

Hope that at least somebody would find this discussion, if he is in similar case to mine.