Hello, I have looked carefully at the system, and, along with what I wrote before, have a couple of speed-up proposals for handling headers (both in searching and in fetching).
(1) Only select the header messageblk when only the header or a part of it is to be fetched on IMAP. Currently, from what I can gather from the logged queries and the code, all messageblks are selected. Note: the code is hard to read and I could find no documentation on the database, so I may be wrong here. If so please correct me... (2) Create an index for the 'messageblk' field in dbmail_messageblks. At least MySQL allows this (can anyone tell me if Postgres does?). Then, on IMAP header field searches, do not load/parse/check; instead, create a regular expression and do a SELECT with it, selecting only header blocks. (MySQL specific again, Postgres comments welcome). This will probably result in a *dramatic* speedup, at the cost of some coding complexity. BTW, why is the "is_header" field unused in dbmail_messageblks? Or at least I found no place in the code that would use it. Is it redundant? If there is no other way to SELECT only header messageblks, it certainly should be used. Yours, Mikhail Ramendik P.S. To be very honest, I did not like the coding style in dbmail. The C language for this task would not be my choice, but never mind that. Functions that are hundreds of lines long, with only minimal comments, are much more problematic. Perl or Python (I prefer Python) with their ready-made RFC822 parsing, along with some DB-expert friends, would help me write an alternative database store quickly. But I really am not up to implementing protocols (SMTP, LMTP, POP3, IMAP). If any Python guru here would go for that, we could try a rewrite :)