Fix N+1 query and add composite index for chat message loading

Performancekamo-shared-library
Shipped
March 12, 2026 at 2:19 AM UTC
Author
Kamo
Commit
1a59c06

- Add LEFT JOIN FETCH m.msg to both repository queries to eagerly load MediaObjMsg in the same query, eliminating up to 100 extra SQL queries per chat window open - Add composite index (SESSION_ID, IS_REMOVED, DATE_CREATED) to cover the message fetch query pattern in a single efficient index scan

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing