﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34011	Implement bulk_create auto-incrementing pk assignment on MySQL when possible	Simon Charette	nobody	"[https://www.godaddy.com/engineering/2022/09/12/rails-bulk-insert-mysql/ From this article] it seems that it might be possible to implement `AutoField` (and friends) assignment on MySQL for `bulk_create` by using a range of `(last_insert_id(), last_insert_id() + affected_rows)` .

[https://dev.mysql.com/doc/refman/8.0/en/innodb-auto-increment-handling.html The criteria are the following]

> Use simple-inserts (e.g. no subquery or insert from select) and don't mix objects with primary keys and ones without.
`bulk_create` doesn't rely on subqueries and [https://github.com/django/django/blob/6220c445c40a6a7f4d442de8bde2628346153963/django/db/models/query.py#L796-L822 it already partitions between objects with and without a primary key].

> Don't use `innodb_autoinc_lock_mode=2` (interleaved) with `binlog_format=STATEMENT`
This is detectable by issuing introspection just like we do with other `connection.features`.

The default on MySQL 5.7 was `(innodb_autoinc_lock_mode=1, binlog_format=STATEMENT)` and is `(innodb_autoinc_lock_mode=2, binlog_format=ROW)` on MySQL 8 which both ensures that ''auto-increment values are assigned in a predictable and repeatable order'' [https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_autoinc_lock_mode as explained in the docs] and thus allows for this feature to be used in setups using default InnoDB configurations."	New feature	closed	Database layer (models, ORM)	4.0	Normal	duplicate			Unreviewed	0	0	0	0	0	0
