#36502: [DJANGO] bulk INSERT is not using UNNEST when a field is a FK on
PostgreSQL
-------------------------------------+-------------------------------------
Reporter: canardoFR | Type:
| Uncategorized
Status: new | Component: Database
| layer (models, ORM)
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Dear Django team,
I'm very fresh & green to Django, but we had to insert millions of lines
into a PostgreSQLtable.
We noticed that the ORM was setting up a "INSERT with UNNEST" for our
bulk_create as long as there was no ForeignKey.
Is related to code here
https://github.com/django/django/blob/main/django/db/backends/postgresql/compiler.py,
line 42 to 45
I made a quick a dirty test by monkey patching the assemble_as_sql
function to created a new list of tested fields ignoring ForeignKey type.
I would have done better by testing the ForeignKey type, but as said
above, to yound and green on django (some days).
I do not know if code is intentional or if this is a bug, thus the ticket
submission.
the patch is attached as a file...
Thanks for reading and cheers,
Alain R.
--
Ticket URL: <https://code.djangoproject.com/ticket/36502>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070197efeb7b27-e7ff97eb-72f7-42a5-b0ef-f22bb88d9dbd-000000%40eu-central-1.amazonses.com.