Open
Description
The chronic-insertions list endpoint is extremely slow and produces over 9000 queries! The detail view is also inefficient, requiring 111 queries. I attempted to improve the setup_eager_loading method of ChronicProbeInsertionListSerializer with the following:
queryset = queryset.select_related('model', 'session', 'session__subject', 'session__lab')
queryset = queryset.prefetch_related('session__projects')
return queryset.order_by('-session__start_time')
However this does not appear to improve the situation.
What's more, the chronic probe insertion contains subject, lab, and name fields in addition to a probe_insertion field containing the same fields within session_info.