unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Sebastian Spaeth <Sebastian@SSpaeth.de>
To: Notmuch developer list <notmuch@notmuchmail.org>
Subject: [PATCH] allow to not sort the search results
Date: Wed, 14 Apr 2010 08:30:55 +0200	[thread overview]
Message-ID: <1271226655-5672-1-git-send-email-Sebastian@SSpaeth.de> (raw)

previously we were always sorting the returned results by some string value,
but sometimes we might just be interested in the number of results, and don't
need any sorting.

Also add a --sort=unsorted command line option to notmuch search to test this.
A search that matches 1200 messages, returns in default sort in 0.982 seconds
and unsorted in 0.978 seconds with very little variance (with a warm cache).
Xapian contributor Olly Betts says that the speed gains for a cold cache are
likely to be much higher though.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
---
 lib/notmuch.h    |    3 ++-
 lib/query.cc     |    2 ++
 notmuch-search.c |    2 ++
 3 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index a7e66dd..bae48a6 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -346,7 +346,8 @@ notmuch_query_create (notmuch_database_t *database,
 typedef enum {
     NOTMUCH_SORT_OLDEST_FIRST,
     NOTMUCH_SORT_NEWEST_FIRST,
-    NOTMUCH_SORT_MESSAGE_ID
+    NOTMUCH_SORT_MESSAGE_ID,
+    NOTMUCH_SORT_UNSORTED
 } notmuch_sort_t;
 
 /* Specify the sorting desired for this query. */
diff --git a/lib/query.cc b/lib/query.cc
index 10f8dc8..4148f9b 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -148,6 +148,8 @@ notmuch_query_search_messages (notmuch_query_t *query)
 	case NOTMUCH_SORT_MESSAGE_ID:
 	    enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE);
 	    break;
+        case NOTMUCH_SORT_UNSORTED:
+	    break;
 	}
 
 #if DEBUG_QUERY
diff --git a/notmuch-search.c b/notmuch-search.c
index 4e3514b..854a9ae 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -217,6 +217,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 		sort = NOTMUCH_SORT_OLDEST_FIRST;
 	    } else if (strcmp (opt, "newest-first") == 0) {
 		sort = NOTMUCH_SORT_NEWEST_FIRST;
+	    } else if (strcmp (opt, "unsorted") == 0) {
+		sort = NOTMUCH_SORT_UNSORTED;
 	    } else {
 		fprintf (stderr, "Invalid value for --sort: %s\n", opt);
 		return 1;
-- 
1.6.3.3

             reply	other threads:[~2010-04-14  6:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-14  6:30 Sebastian Spaeth [this message]
2010-04-14  6:55 ` [PATCH] allow to not sort the search results Jason White
2010-04-14  7:51   ` Sebastian Spaeth
2010-04-15 12:54     ` Olly Betts
2010-04-16  6:37       ` Sebastian Spaeth
2010-04-16  6:38         ` [PATCH 1/3] query.cc: allow to return query results unsorted Sebastian Spaeth
2010-04-16  6:38         ` [PATCH 2/3] notmuch-search: Introduce --sort=unsorted Sebastian Spaeth
2010-04-16  6:38         ` [PATCH 3/3] notmuch-tag: don't sort messages before applying tag changes Sebastian Spaeth
2010-04-16  6:58         ` [PATCH] allow to not sort the search results Olly Betts
2010-04-18 13:56         ` Sebastian Spaeth
2010-04-21 23:09           ` Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1271226655-5672-1-git-send-email-Sebastian@SSpaeth.de \
    --to=sebastian@sspaeth.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).