Skip to content

Remove useless fields from various complex SQL queries

Erwan Rouchet requested to merge defer-fields into master

Requires !1406 (merged)

While spending a lot of time updating all the SQL assertions, I noticed many queries were now asking for an image ID and a polygon for no reason. This can cause the queries to be unnecessarily slowed down as deserializing polygons is slow due to the Django PostGIS bindings being slow. This was not really an issue before since we only fetched a zone ID, but now that we are fetching polygons more often, this could become more noticeable.

This applies .only() wherever possible, only in endpoints that were covered by assertExactQueries. Using #708 (closed), along with a default .defer('polygon') could enable us to detect some useless SQL queries being made in other endpoints.

Edited by Erwan Rouchet

Merge request reports

Loading