Ross Becker writes:
I'm looking at hacking maildrop and Courier-IMAP to maintain
fixed-length record list files containing the message headers needed to
support standard SEARCH, SORT, and THREAD operations. At a wild guess,
this should provide an order of magnitude speed improvement.
Clearly, for a webmail system, you want the server to be able to sort
the messages fast, because all sorts happen on the imap server. If
anyone else here is interested in this hack, has thoughts, or feedback-
I'm all ears.
Clearly, for a webmail software -- or any other IMAP client -- it's rather
dumb to have it ask the server to sort, and resort, and resort the same set
of messages, over and over again. Why waste, time, and time again, doing
the same thing.
In case of a typical webmail software, the answer is usually poor design;
that the webmail software is nothing but a glorified script: for each
request from the browser log on to the IMAP server, issue a single request,
and log off. So when browsing the folder's contents in a particular sort
order, each request consists of logging in to the server, sorting the
folder, and displaying a subset of the sorted index.
The solution here is to come up with a proper design for the webmail
software, and to implement it properly, instead of burdening the server with
the task of computing even more folder-related data. A server is a shared
resource. Any additional work by the server impacts every client using the
server.
Furthermore, you will notice that any real IMAP mail client, whose number of
users exceeds background noise, never has any use for SORT, or THREAD. Why's
that? Well, because you don't want the IMAP mail client to have to go and
wait for the server's response whenever you scroll through the folder's
contents. That's why you need to download the contents of the folder, so
that it can be paged through without any delay. And to minimize the delay
on opening the folder the IMAP mail client should using caching to download
only the minimum set of changes to the folder.
So when it's time to re-sort the folder into a different order, it makes
no sense whatsoever to have the client issue a server request, and wait for
the response. That's because the client already has the entire folder's
contents available, and it has all the metadata needed to re-sort the
folder, by itself, without burdening the server that has to reply to several
thousand other IMAP clients.