about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-02 00:04:55 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-02 00:05:42 +0000
commit87dca6d8d5988c5eb54019cca342450b0b7dd6b7 (patch)
treea415a88759b88014d30544addbb69c5949ed76f0 /lib/PublicInbox/Search.pm
parent3cc5ff405d9054fbf47ac44774fca4f9a72ff65a (diff)
downloadpublic-inbox-87dca6d8d5988c5eb54019cca342450b0b7dd6b7.tar.gz
In many cases, we do not care about the total number of
messages.  It's a rather expensive operation in SQLite
(Xapian only provides an estimate).

For LKML, this brings top-level /$INBOX/ loading time from
~375ms to around 60ms on my system.  Days ago, this operation
was taking 800-900ms(!) for me before introducing the SQLite
overview DB.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 91251246..84c0a22f 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -185,10 +185,16 @@ sub get_thread {
 
 sub retry_reopen {
         my ($self, $cb) = @_;
-        my $ret;
         for my $i (1..10) {
-                eval { $ret = $cb->() };
-                return $ret unless $@;
+                if (wantarray) {
+                        my @ret;
+                        eval { @ret = $cb->() };
+                        return @ret unless $@;
+                } else {
+                        my $ret;
+                        eval { $ret = $cb->() };
+                        return $ret unless $@;
+                }
                 # Exception: The revision being read has been discarded -
                 # you should call Xapian::Database::reopen()
                 if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') {
@@ -226,8 +232,9 @@ sub _enquire_once {
         my @msgs = map {
                 PublicInbox::SearchMsg->load_doc($_->get_document);
         } $mset->items;
+        return \@msgs unless wantarray;
 
-        { total => $mset->get_matches_estimated, msgs => \@msgs }
+        ($mset->get_matches_estimated, \@msgs)
 }
 
 # read-write