django-bulk-update-or-create icon indicating copy to clipboard operation
django-bulk-update-or-create copied to clipboard

Add option to use bulk_create for creating non-multi-table models

Open WilliamYuhangLee opened this issue 10 months ago • 1 comments

Add option to use bulk_create for creates: assert model is not multi-table, if enabled

Hi, as listed in one of the Todos, do you have a timeline for adding this option?

Your library otherwise provides so much convenience for bulk-upserting, but when it comes to simple models, using bulk creates would be so much faster than individual creates!

WilliamYuhangLee avatar Apr 04 '24 14:04 WilliamYuhangLee

Hi, I’m not actively using this package at the moment so developing new features is on hold. I’m happy to take PRs though! I imagine something such as:

  • “use_bulk_create” keyword argument that defaults to “auto”
  • If “auto”, detect if model can use bulk create or not (multi table, maybe other conditions?)
  • If it can, use it. If it cannot, do single creates and log warning (that can be disabled by explcitly setting the option to False) - this makes it clear to caller about future performance hits
  • If True and bulk cannot be used, throw error

fopina avatar Apr 04 '24 22:04 fopina