"search return (min)" is very inefficient

Jesus Cea jcea at jcea.es
Tue Feb 13 02:04:30 EET 2018


RFC 4731: " IMAP4 Extension to SEARCH Command for Controlling
                  What Kind of Information Is Returned"

https://tools.ietf.org/html/rfc4731

I do this (telnet session):

"""
a select proveedores/TUHS
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)]
Flags permitted.
* 8330 EXISTS
* 0 RECENT
* OK [UNSEEN 6085] First unseen.
* OK [UIDVALIDITY 1395814416] UIDs valid
* OK [UIDNEXT 8358] Predicted next UID
* OK [HIGHESTMODSEQ 3149] Highest
a OK [READ-WRITE] Select completed (0.264 + 0.000 + 0.263 secs).
a search return (min) since 01-Feb-2018
* ESEARCH (TAG "a") MIN 8156
a OK Search completed (59.451 + 0.000 + 59.450 secs).
"""

Note that it needs 59 seconds to locate the first message matching the
"since" criteria. This is really slow and unusable in practice. Things
are worse with bigger mailboxes, of course.

Am I missing some performance trick?.

I am trying to locate the first message received after a particular
date. I don't use the "date" header because it can be falsified and
because I care about the receiving date and not the actual sending date.

I guess dovecot is scanning every message in the folder (mailbox).
Wouldn't those messages be stored in ascending "received" order?. Could
that be used for bisection search to locate the right message?. Could
that break if I copy/move/edit messages?. Is that the reason for such a
awful performance?.

Suggestions?.

Thanks for your time and knowledge!.

-- 
Jesús Cea Avión                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
Twitter: @jcea                        _/_/    _/_/          _/_/_/_/_/
jabber / xmpp:jcea at jabber.org  _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://dovecot.org/pipermail/dovecot/attachments/20180213/519080e7/attachment-0001.sig>


More information about the dovecot mailing list