[PATCH v2 9/9] cli: do not sort addresses on --output=count or --deduplicate=address
Jani Nikula
jani at nikula.org
Thu Sep 3 12:40:05 PDT 2015
The order of the results with --output=count and --deduplicate=address
are unspecified as they're based on a hash table traversal. This being
the case, optimize the query by explicitly requesting unsorted
results. Clarify the documentation accordingly.
---
doc/man1/notmuch-address.rst | 4 +++-
notmuch-search.c | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst
index b85cc37213e5..cbdb851980a8 100644
--- a/doc/man1/notmuch-address.rst
+++ b/doc/man1/notmuch-address.rst
@@ -85,7 +85,9 @@ Supported options for **address** include
By default, results will be displayed in reverse chronological
order, (that is, the newest results will be displayed first).
- This option is not supported with --output=count.
+ However, if either --output=count or --deduplicate=address is
+ specified, this option is ignored and the order of the results
+ is unspecified.
``--exclude=(true|false)``
A message is called "excluded" if it matches at least one tag in
diff --git a/notmuch-search.c b/notmuch-search.c
index deb9e58a747c..b58496bf09d5 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -885,6 +885,11 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
_talloc_free_for_g_hash,
_list_free_for_g_hash);
+ /* The order is not guaranteed if a full pass is required, so go
+ * for fastest. */
+ if (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS)
+ notmuch_query_set_sort (ctx->query, NOTMUCH_SORT_UNSORTED);
+
ret = do_search_messages (ctx);
g_hash_table_unref (ctx->addresses);
--
2.1.4
More information about the notmuch
mailing list