Subject: [lemonade] WITHIN draft review

From: Arnt Gulbrandsen <[email-masked]>
Date: Mon, 13 Mar 2006 16:54:58 +0100

Hi,

some thoughts on that. Small issues first, big at the end.

First, let me say that I've needed an extension like this for some 
months, and the only reason I haven't written an extension like it 
myself is that I couldn't solve the problem I describe at the end.

1. There are some nits. Formatting problems. Lots of windows smartquotes 
and so on, while drafts should be in US-ASCII.

The formal syntax is wrong, there should be an SP between "WITHIN" and number.

2. The name of the search-key is somewhat at odds with the way IMAP does 
things.

Mostly, IMAP uses search keys called x and UNx. SEEN/UNSEEN, 
KEYWORD/UNKEYWORD, SENTSINCE/SENTBEFORE. This may or may not be a good 
idea, but it's existing practice. If this extension is to fit well into 
IMAP, then I suggest that it calls its search-keys like OLDER/YOUNGER, 
instead of NOT WITHIN/WITHIN.

3. Mostly, IMAP uses days for such things, and disregards timezones when 
comparing times. See the bottom part of RFC 3501 page 52, for example. 
WITHIN uses seconds, and does not mention timezones.

4. As far as I can see from the draft, WITHIN corresponds to SENTSINCE 
etc, not SINCE etc. That is, WITHIN cannot be used to search for all 
mail which has been received during the past two days.

SEARCH NOT WITHIN 604800 seaches for all mail which is _dated_ more than 
a week ago. Not mail which was _received_ more than a week ago.

I'm not sure which of the two is more desirable. It would be possible to 
have both by extending IMAP differently - using "-" nz-number as an 
alternative to time-date in SENTSINCE and friend. Instead of SEARCH NOT 
WITHIN 604800, the extension could say SEARCH SENTBEFORE -7 to find 
messages sent more than 7 days ago. Or it could say SEARCH SEARCH 
BEFORE -7 to search for mail which was received more than 7 days ago.

5. The big, big problem.

WITHIN+VFOLDER are difficult to implement correctly and effciently. Take 
a search such as 'UNSEEN NOT WITHIN 86400', ie. a search for all unread 
messages older than one day.

The UNSEEN bit of the search changes only when the mailbox' modsequence 
increases (or equivalent for servers which don't implement CONDSTORE). 
However, WITHIN changes potentially every second, even when nothing 
happens to the mailbox.

So, in order to perform this search accurately, the server has to 
perform the search almost every time the client sends an IMAP command. 
If the mailbox is big, that's awfully expensive.

There are two ways out of this, as far as I can see.

One is to use day resolution for WITHIN. In that case, the server 
generally only has to reevaluate the search when the 
modsequence/uidnext changes, and once per day additionally. Not too 
bad.

The other is to add special rules to say that, in effect, if WITHIN 
matches a message once in a mailbox session, it matches that message 
until the end of the session. In other words, WITHIN uses the time of 
the SELECT/EXAMINE as basis, not the current time. (I dislike this, for 
several reasons. Will elaborate on request, but this mail is long 
enough already.)

Arnt

_______________________________________________
lemonade mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/lemonade