mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-18 07:37:56 +02:00
On the media_auth endpoint the first bottleneck we have is with postgresql. We are looking for too much data and no index is used on the attachments colum. When the lookup filter on the attachement columns, a full scan is made on all the document table looking for each element in the array, this operation is really expensive. To fix this we created a GIN index on the attachments column. Also the readable_per_se lookup was selecting too much data combined with the filter_descendants function. We remove the usage of the filter_descendants, we choose to first fetch all the paths where the attachment is found, this operation is fast thanks to the new index, split all the paths in candidate paths and then filter readable_per_se queryset with these paths. All these modifications make the endpoint faster.