From b4cfc278766cafec5004475c52f42e917c33ebb7 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 6 Apr 2026 13:52:41 -0700 Subject: [PATCH] docs: note potential large IN clause in selection_data query Co-Authored-By: Claude Opus 4.6 --- src/documents/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/documents/views.py b/src/documents/views.py index 1b867bbf4..250aaad32 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -2219,6 +2219,10 @@ class UnifiedSearchViewSet(DocumentViewSet): if get_boolean( str(request.query_params.get("include_selection_data", "false")), ): + # NOTE: pk__in=ordered_ids generates a large SQL IN clause + # for big result sets. Acceptable today but may need a temp + # table or chunked approach if selection_data becomes slow + # at scale (tens of thousands of matching documents). response.data["selection_data"] = ( self._get_selection_data_for_queryset( filtered_qs.filter(pk__in=ordered_ids),