﻿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
34631	Expression.identity() performance	Blaž Šnuderl	nobody	"Expression class defines an identity uses that relies heavily on reflection/inspect to generate identity of its objects. This is generally gonna be slow and does a lot of extra work compared to hand writing these identity expressions.

Based on some simple profiling in our project, I saw a lot of query building time being spent in this identity function. Atleast for simple queries vast majority of Expression objects are ''Col'', one per column in the model.

My proposal would be to optimize atleast this case, but potentially we can also explore whether we need such complicated identity and all and if we could avoid the inspect calls in general.

I have opened a very simple PR demonstrating a possible improvement here https://github.com/django/django/pull/16940 and it passes all django tests and I also ran it on our projects test suite without issues."	Cleanup/optimization	closed	Database layer (models, ORM)	4.2	Normal	wontfix		David Sanders Simon Charette	Unreviewed	0	0	0	0	0	0
