[PATCH 2/2] lib: handle empty string in regexp field processors

David Bremner david at tethera.net
Sat Mar 25 04:30:00 PDT 2017

David Bremner <david at tethera.net> writes:

> +    if (str.size () == 0)
> +	return Xapian::Query(Xapian::Query::OP_AND_NOT,
> +			     Xapian::Query::MatchAll,
> +			     Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix));
> +

Full disclosure, this is a pretty expensive query. On an older i7, it
takes about 7.5s (elapsed) on my 466k messages to find 702 messages
without a subject.  I don't think it's a big deal, since I don't think

     notmuch search 'subject:""'

is likely to be typed by mistake.

For comparison, "grep -R '^Subject:$'" (which is not exactly the same
query,  since some messages completely lack a Subject: line).
takes about 390s (elapsed).

More information about the notmuch mailing list