From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 464E76DE024A for ; Wed, 11 Jan 2017 18:01:25 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1lGhjjOUGX8I for ; Wed, 11 Jan 2017 18:01:24 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id D1D026DE01CE for ; Wed, 11 Jan 2017 18:01:23 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cRUhB-0005Tg-Le; Wed, 11 Jan 2017 21:00:53 -0500 Received: (nullmailer pid 12545 invoked by uid 1000); Thu, 12 Jan 2017 02:01:19 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH] lib: optimize counting documents Date: Wed, 11 Jan 2017 22:01:15 -0400 Message-Id: <20170112020115.12503-1-david@tethera.net> X-Mailer: git-send-email 2.11.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2017 02:01:25 -0000 >From #xapian olly> bremner: btw, i noticed notmuch count see ms to request all the documents and then ignores them bremner> hmm. There's something funny about the way that notmuch uses matches in general iirc olly> it should be able to do: mset = enquire.get_mset (0, 0, notmuch->xapian_db->get_doccount ()); ... olly> get_matches_estimated() will be exact because check_at_least is the size of the database --- lib/query.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/query.cc b/lib/query.cc index 53efd4e1..4ccd8104 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -606,8 +606,9 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign /* * Set the checkatleast parameter to the number of documents * in the database to make get_matches_estimated() exact. + * Set the max parameter to 0 to avoid fetching documents we will discard. */ - mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount (), + mset = enquire.get_mset (0, 0, notmuch->xapian_db->get_doccount ()); count = mset.get_matches_estimated(); -- 2.11.0