Commit graph

3 commits

Author SHA1 Message Date
Simon Charette
0fe218842e
Fixed #36502 -- Restored UNNEST strategy for foreign key bulk inserts on PostgreSQL.
Some checks failed
Docs / docs (push) Has been cancelled
Tests / Windows, SQLite, Python 3.13 (push) Has been cancelled
Tests / JavaScript tests (push) Has been cancelled
Linters / black (push) Has been cancelled
Docs / blacken-docs (push) Has been cancelled
Linters / flake8 (push) Has been cancelled
Linters / isort (push) Has been cancelled
Regression in 764af7a3d6.
2025-07-10 18:33:00 +02:00
Simon Charette
4608d34b34 Fixed #36088 -- Avoided unnecessary DEFAULT usage on bulk_create().
When all values of a field with a db_default are DatabaseDefault, which
is the case most of the time, there is no point in specifying explicit
DEFAULT for all INSERT VALUES as that's what the database will do anyway
if not specified.

In the case of PostgreSQL doing so can even be harmful as it prevents
the usage of the UNNEST strategy and in the case of Oracle, which
doesn't support the usage of the DEFAULT keyword, it unnecessarily
requires providing literal db defaults.

Thanks Lily Foote for the review.
2025-02-01 18:43:10 +01:00
Simon Charette
a16eedcf9c Fixed #35936 -- Used unnest for bulk inserts on Postgres when possible.
This should make bulk_create significantly faster on Postgres when provided
only literal values.

Thanks James Sewell for writing about this technique, Tom Forbes for
validating the performance benefits, David Sanders and Mariusz Felisiak
for the review.
2024-12-11 13:56:18 +01:00