Opened 4 years ago

Last modified 16 months ago

#18669 new Bug

QuerySet.bulk_create should batch if no AutoField

Reported by: Jeremy Dunck Owned by: Jeremy Dunck
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: QuerySet.bulk_create
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

.bulk_create branches on can_combine_inserts_with_and_without_auto_increment_pk *and* _meta.has_auto_field, but it should be
can_combine_inserts_with_and_without_auto_increment_pk or not _meta.has_auto_field.

https://github.com/django/django/blob/f3c9a16a423c90baaf3804cb050d320741f799a2/django/db/models/query.py#L421

This buglet means that even if the model doesn't have an autofield, the list will be partitioned into models with and without the PK, resulting in unnecessary query executions.

I'm assigning myself as owner because I intend to patch it.

Change History (2)

comment:1 Changed 4 years ago by Anssi Kääriäinen

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Looks like a bug to me.

comment:2 Changed 16 months ago by Tim Graham

Keywords: QuerySet.bulk_create added
Note: See TracTickets for help on using tickets.
Back to Top