#36815: Avoid unnecessary prepare_value calls when inserting db_defaults
-------------------------------------+-------------------------------------
Reporter: Adam Sołtysik | Owner:
Type: | YashRaj1506
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by YashRaj1506):
Okay so i went through this, and i actually didnt notice a pr was
attatched but my solution is also exactly what Adam came up with. "
Ignoring the `field_prepare(field_pre_save(obj))` from happening if it is
a `DatabaseDefault`object and just passing the value we get from
`field_pre_save(obj)` so that we dont break any operation which is
happening after this point.
I borrowed the test from adams pr and everything passed nicely, also
improving the benchmark.
without new code
{{{
(djangodev) yash@pop-os:~/Desktop/36815/django/tests$ python runtests.py
bulk_create
Testing against Django installed in
'/home/yash/Desktop/36815/django/django' with up to 16 processes
Found 60 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
System check identified no issues (0 silenced).
...0.217
.............s.........................s...s...s......sss
----------------------------------------------------------------------
Ran 60 tests in 0.368s
OK (skipped=7)
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
}}}
with imrpovements:
{{{
(djangodev) yash@pop-os:~/Desktop/36815/django/tests$ python runtests.py
bulk_create
Testing against Django installed in
'/home/yash/Desktop/36815/django/django' with up to 16 processes
Found 60 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
System check identified no issues (0 silenced).
...0.117
.............s.........................s...s...s......sss
----------------------------------------------------------------------
Ran 60 tests in 0.275s
OK (skipped=7)
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'..
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36815#comment:10>
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/0107019b85614ab8-60b92ae6-aa47-4fe1-874f-0c9a23a9e60d-000000%40eu-central-1.amazonses.com.