This is intended to fix the slow behaviour of "notmuch new" (and possibly
"notmuch reindex") when large numbers of files are deleted.
The underlying issue  seems to be the Xapian glass backend spending
a large amount of time in db.has_positions when running queries with
large-ish amounts of unflushed changes.
This commit removes two uses of Xapian queries , and replaces them with
an approximation of what Xapian would do after optimizing the
queries. This avoids the calls to has_positions (which are in any case
un-needed because we are only using boolean terms here).
 Thanks to "andres" on IRC for narrowing down the performance
 Thanks to Olly Betts of Xapian fame for talking me a through a fix
that does not require people to update Xapian.
lib/message.cc | 68 +++++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 29 deletions(-)