+++ This bug was initially created as a clone of Bug #1846885 +++
Bug 1846885 should have used the first version of the patch:
This code here:
causes a significant performance regression for search folders:
as the operation is very expensive and also leaves all the databases open which is rather counterproductive when looking at fixing bug 1554188.
In general, all callers of nsMsgDBView::FindIndexOfMsgHdr() (which calls nsMsgDBView::FindHdr()) now potentially suffer performance issues and cause more open databases. Even displaying a message in a search folder now visits all the folders/databases it is made up of:
Screenshot of profiling of this case. User was simply selecting messages in search folder spanning apparently 56 mailboxes.
Some correction is needed here: For search views, FindHdr() is overridden here:
https://searchfox.org/comm-central/rev/f03f68a187cad017819657991b2fc67817b9887e/mailnews/base/src/nsMsgSearchDBView.cpp#1130, sadly that's not visible in the performance profile. A profile with all function names shows nsMsgDBView::FindIndexOfMsgHdr() calling nsMsgSearchDBView::FindHdr().
That said, we would still advise to deploy our patch which restores the initial proposal from bug 1846885 since the backend change isn't warranted just to save one line of JS in the frontend for a very uncommon operation to select a message by header from the click onto a new message notification.