cortex-lab / cortex-lab/alyx

Chronic insertions view in need of optimization

Open
#894 2 comments 0 reactions 1 assignee View on GitHub

@k1o0 is already working on this.

Since Aug 14, 2026.

enhancement refactor rest-api
Dominant language
Python
Stars
52
Forks
12
Avg merge
1d 11h
Merged PRs (30d)
4

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.