﻿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
36815	Avoid unnecessary prepare_value calls when inserting db_defaults	Adam Sołtysik	YashRaj1506	"In `SQLInsertCompiler.as_sql`, it looks like `prepare_value` is unnecessarily called for each `DatabaseDefault` value on every inserted object. These calls are quite expensive (as they enter the `if hasattr(value, ""resolve_expression"")` branch) and waste a lot of time when using `bulk_create`.

I've written a potential patch and a simple benchmark: https://github.com/adamsol/django/commit/d6f275c8960988c92a9da5eb323b6bd6fc7717cb. The benchmark runs 2x faster with the fix, even though there's only one field with `db_default` in that model. The difference may become larger with more fields."	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed		Nilesh Pahari	Ready for checkin	1	0	0	0	0	0
