diff options
author | Austin Clements <amdragon@MIT.EDU> | 2010-11-17 14:28:26 -0500 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-12-07 16:40:05 -0800 |
commit | b3caef1f0659dac8183441357c8fee500a940889 (patch) | |
tree | c8da072401a13637e0ef40f432372b15367cde3d /lib/notmuch-private.h | |
parent | e2556542325a74bb0284ae21764c58249dd7bef7 (diff) |
Optimize thread search using matched docid sets.
This reduces thread search's 1+2t Xapian queries (where t is the
number of matched threads) to 1+t queries and constructs exactly one
notmuch_message_t for each message instead of 2 to 3.
notmuch_query_search_threads eagerly fetches the docids of all
messages matching the user query instead of lazily constructing
message objects and fetching thread ID's from term lists.
_notmuch_thread_create takes a seed docid and the set of all matched
docids and uses a single Xapian query to expand this docid to its
containing thread, using the matched docid set to determine which
messages in the thread match the user query instead of using a second
Xapian query.
This reduces the amount of time required to load my inbox from 4.523
seconds to 3.025 seconds (1.5X faster).
Diffstat (limited to 'lib/notmuch-private.h')
-rw-r--r-- | lib/notmuch-private.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 592cfb2b..303aeb30 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -156,6 +156,8 @@ typedef enum _notmuch_private_status { : \ (notmuch_status_t) private_status) +typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t; + /* database.cc */ /* Lookup a prefix value by name. @@ -222,8 +224,8 @@ _notmuch_directory_get_document_id (notmuch_directory_t *directory); notmuch_thread_t * _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, - const char *thread_id, - const char *query_string, + unsigned int seed_doc_id, + notmuch_doc_id_set_t *match_set, notmuch_sort_t sort); /* message.cc */ @@ -239,6 +241,9 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch, const char *message_id, notmuch_private_status_t *status); +unsigned int +_notmuch_message_get_doc_id (notmuch_message_t *message); + const char * _notmuch_message_get_in_reply_to (notmuch_message_t *message); @@ -426,6 +431,14 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages); void _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages); +notmuch_bool_t +_notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids, + unsigned int doc_id); + +void +_notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids, + unsigned int doc_id); + /* message.cc */ void |