Maybe this is just noise... but I can reproduce this fairly reliably.
Mailbox with 21,000+ messages
This query:
a UID SORT RETURN (ALL COUNT) (DATE) UTF-8 SUBJECT "foo"
is always about 10 percent slower than this split query (I've done
this 4-5 times, and the numbers are similar):
a UID SEARCH RETURN (SAVE) CHARSET UTF-8 SUBJECT "foo" b UID SORT RETURN (ALL COUNT) (DATE) UTF-8 UID $
(The particular query I used matched 5 messages out of the 21,000+)
My not-very-scientific benchmarking process:
1.) Stop dovecot process 2.) Delete all dovecot index files for that mailbox 3.) Flush linux paging cache (sync && echo 3 > /proc/sys/vm/drop_caches) 4.) Restart dovecot 5.) Access dovecot via command-line (PREAUTH) 6.) SELECT mailbox 7.) Issue command(s)
Could be a potential area for performance improvement or could simply
be lazy benchmarking.
michael