I just read about the courier imapd and in particular how it implements
quota for maildir:
http://www.inter7.com/courierimap/README.maildirquota.html
"3.If the filename of each message is of the form xxxxx,S=nnnnn or
xxxxx,S=nnnnn:xxxxx where "xxxxx" represents arbitrary text, then use
nnnnn as the size of the file (which will be conveniently recorded in
the filename by a Maildir++ writer, within the conventions of filename
naming in a Maildir). If the message was not written by a Maildir++
writer, stat() it to obtain the message size. If stat() fails, a race
condition removed the file, so just ignore it and move on to the next one."
Encoding the filesize in the name avoids a stat(2), which should make
quota calculation MUCH faster.
Michael