From b3caef1f0659dac8183441357c8fee500a940889 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 17 Nov 2010 14:28:26 -0500 Subject: 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). --- lib/message.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/message.cc') diff --git a/lib/message.cc b/lib/message.cc index 225b7e91..adcd07d6 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -254,6 +254,12 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch, return message; } +unsigned int +_notmuch_message_get_doc_id (notmuch_message_t *message) +{ + return message->doc_id; +} + const char * notmuch_message_get_message_id (notmuch_message_t *message) { -- cgit v1.2.3