I'm currently working on a web mail client. When a user logs in, I'm fetching all the mails from the INBOX from the beginning of time. As expected this is pretty darn slow. I'm planning to implement some sort of a filtering/caching technique and was looking for some ideas.
If I fetch all the message numbers, trim them and sort them in a descending order, will I have messages from the the last message received to the first? Also, would it be preferable to store mails in a intermediate database and fetch them from there?