diff --git a/HellionChat/MessageStore.cs b/HellionChat/MessageStore.cs index dd5f51f..bce9cae 100644 --- a/HellionChat/MessageStore.cs +++ b/HellionChat/MessageStore.cs @@ -1001,12 +1001,18 @@ internal class MessageStore : IDisposable // SQL narrows by Receiver + ChatType (indexed); client does the final // PlayerPayload comparison. sqlScanLimit caps the scan to stay within // the message-processing worker thread budget. + // Walks the full receiver-filtered tell history newest-first and stops + // as soon as the per-partner match count reaches `limit`. The previous + // hardcoded 500-row scan window cut active users' less-frequent pinned + // partners out of the result whenever other partners' chatter pushed + // them off the back of the window. Index on (Receiver, Date) keeps the + // SQL side cheap; the client-side break bounds the actual decode cost + // to roughly the depth at which `limit` partner matches accumulate. internal IReadOnlyList GetTellHistoryWithSender( ulong receiver, string senderName, uint senderWorld, - int limit, - int sqlScanLimit = 500 + int limit ) { if (limit <= 0) @@ -1024,14 +1030,12 @@ internal class MessageStore : IDisposable WHERE deleted = false AND Receiver = $Receiver AND ChatType IN ($TellIncoming, $TellOutgoing) - ORDER BY Date DESC - LIMIT $ScanLimit; + ORDER BY Date DESC; "; cmd.CommandTimeout = 60; cmd.Parameters.AddWithValue("$Receiver", receiver); cmd.Parameters.AddWithValue("$TellIncoming", (int)ChatType.TellIncoming); cmd.Parameters.AddWithValue("$TellOutgoing", (int)ChatType.TellOutgoing); - cmd.Parameters.AddWithValue("$ScanLimit", sqlScanLimit); var collected = new List(); using var enumerator = new MessageEnumerator(cmd.ExecuteReader(), _logger);