0

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?

1

Why don't you reverse the order of your retrieval? Instead of starting at the beginning of time, start at the end of time (ie. most recent) and then go back in time.

Users looking at mail want to see what's most recently come in, they don't care as much about what was sent to them last week or even last year.

Another option to consider is an skip-take fetch process. Instead of waiting for everything to be fetched from the database.

  • Retrieve the 20 most recent messages
  • Return those to the client
  • Get the next 20 most recent messages
  • Return those to the client
  • Repeat as needed
  • Would introducing a intermediate database introduce more variables in the mix? Would making clever use of sessionStorage help? Thanks btw! :) – Abijeet Patro Feb 19 '14 at 19:04
  • @AbijeetPatro - sounds like you would have 3 problems instead of just 1. – GlenH7 Feb 19 '14 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.