Skip to content

Performance optimisation for LDListMixin

Sylvain Lehmann requested to merge resolve_parent_performance_optimisation into master

The LDListMixin call Model.resolve_parent(self.context['request'].path) to get parent model from request. This instruction result in a SQL request on each call to get the model.

The problem is that the parent function is called on each container serialization : this result a similar SQL request for each ManyToManyField or related ForeignKey field of every object serialized. This is a major performance bottleneck when serializing a large container.

I propose to put this request on a request middleware, and use the result in LDListMixin

Merge request reports