I have a class that I store in a LiteCollection:
public class Message {
public string Id => $"{ChannelId}-{MessageId}";
public long ChannelId { get; set; }
public long MessageId { get; set; }
public string Text { get; set; }
...
}
MessageID
can be duplicate, ChannelID
is unique.
For the test, I added 700k random messages to the collection. But I think in reality there will be more.
Now it takes 70 ms to receive a specific message by identifier, and 140 ms in total from MessageID and ChannelID.
Given that the number of elements will increase, how do I optimize this?
It can not just throw everything into one collection, but, for example:
- make a new collection for the channel to make a channel class, and in
- it store all messages related to this channel?