Conversation
RankoR
marked this pull request as ready for review
September 17, 2026 21:07
RankoR
requested review from
inthewaves,
m4pl and
sdsantos
and removed request for
inthewaves and
m4pl
September 17, 2026 21:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #304
The screen loaded the whole conversation in one query and held every message in memory. The query groups on
messages._idand orders byreceived_timestamp, so SQLite sorted the entire thread into temp b-trees before it could return a single row - 35 s and ~98 MB of Java heap for an 80000-message conversation, with an empty screen the whole time.Fix:
LIMITin a subquery overmessages, before the joins and theGROUP BY. ALIMITon the outer statement doesn't help - the sort still runs over the whole conversation first. Bounding the subquery bounds both temp b-trees to the window.(conversation_id, received_timestamp)index, schema v5.index_messages_sortcan't serve this query:statussits between those two columns and is filtered with a non-indexable<>.Benchmarks:
Scrolling back through the 80,000-message thread, window doubling each time:
Java heap after flinging back to 4,000 loaded messages: 76 MB - still below what the old code needed just to open the thread.
One-time v4 -> v5 upgrade on that database: 36 ms. The index costs 1.4 MB for 80,000 messages.