SIGN IN SIGN UP

bugfix: message panel crashes via large chat volume (#6191)

* fix: replace full message load in stats endpoint with SQL COUNT queries

* fix: replace full message load in stats endpoint with SQL COUNT queries

Loading all messages into memory to compute stats caused OOM crashes with
large chat volumes. Replaced with parallel SQL COUNT queries that never load
message rows. The feedbackTypes filter now uses a correlated subquery to
avoid hitting PostgreSQL's parameter limit at high feedback volumes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feedback filters were incorrectly filtering messages with feedback of the WHOLE session, instead of just the feedback + previous message. Added code to count preceding messages as count to mimic previous functionality

* fix: consolidate stats queries from 4 round-trips into 1 combined query

Replace 4 separate COUNT QueryBuilders (totalMessages, totalSessions,
totalFeedback, positiveFeedback) with a single query using addSelect
and CASE WHEN for the positive feedback breakdown. When a feedbackTypes
filter is active, reduce from 5 round-trips down to 2 (combined + preceding).
Update tests to match the new single getRawOne call and aliased column names.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
J
jchui-wd committed
e10a4ca0d8272e890135521597c32f01dd48ad25
Parent: 42b9157
Committed by GitHub <noreply@github.com> on 4/17/2026, 9:09:49 PM