#3905: very slow IMAP search --------------------+--------------------- Reporter: jeffpc | Owner: brendan Type: defect | Status: new Priority: major | Milestone: Component: IMAP | Version: 1.7.1 Keywords: | --------------------+--------------------- I think I found a O(n^2) behavior in mutt's imap code. If I open a mailbox with ~230k emails, and then do a tag-pattern with =h"foo: bar" (which tags ~209k emails), the UI "freezes" and mutt starts consuming 100% CPU.
My guess is that it's doing something like: {{{ for each UID returned by the SEARCH: uid2msgno() }}} uid2msgno() seems to iterate through all emails in the mailbox trying to match the UID. In my case, it took 13 '''minutes''' of CPU for the search to complete. If the "msgno" returned by uid2msgno() is the same as IMAP MSNs, then instead of doing a UID SEARCH mutt should use SEARCH. It looks like the comment above uid2msgno() acknowledges that the linear scan is far from optimal. It also looks like cmd_parse_search() is calling uid2msgno() twice for no good reason. -- Ticket URL: <https://dev.mutt.org/trac/ticket/3905> Mutt <http://www.mutt.org/> The Mutt mail user agent