Il 02/10/2018 12:08, Timo Sirainen ha scritto:

On 2 Oct 2018, at 12.22, Alessio Cecchi <alessio@skye.it> wrote:

Hello,

we are developing a library to show last arrived messages of all threads in a folder with more than 300k messages.

As per the RFC 5256, the IMAP thread command has only the option to specify the grouping criteria (REFERENCES vs ORDEREDSUBJECT). So we implemented an algorithm which gets the full UID SORT ordered by date in reverse order then gets all thread relations and then post process all outputs to obtain the final result.

It sounds like what you want is REFS threading, which Dovecot supports, but it didn't make it into official RFC: https://tools.ietf.org/html/draft-gulbrandsen-imap-inthread-05

Thanks Timo,

you are the best!

p.s. was a pleasure to meet you and the OX team in Rome last week
-- 
Alessio Cecchi
Postmaster @ http://www.qboxmail.it
https://www.linkedin.com/in/alessice