Hello, Apart from future rewrites, I think I have an idea that can *seriously* speed up current code - at the cost of adding redundancy to the database (and adding a field, and writing an upgrade script).
We add a header_messageblk_idnr field to the dbmail_messages table. It should contain the messageblk_idnr of the messageblk that contains the header of this message. This will help us speed up IMAP header fetches, probably to the possible maximum. All the queries *except* the messageblk query in _im_fetch() can be united into one or two "global" queries, one per fetch, not one per message. Then we buffere the data in RAM, along with the header_messageblk_idnr for every message to be fetched. Now, for every mesage, we just run a query for one table, dbmail_messageblks, and on an indexed field too! This query will likely be *very* fast. This is also useful for searches, especially if we don't rewrite the searching code itself as yet. The header for every message that has to be parsed/searched will be delivered somewhat fastet this way. But of course, the main improvement will be for FETCHes. Incidentally. this is the threshold that needs to be crossed before dbmail is usable for me personally ;) Yours, Mikhail Ramendik