about summary refs log tree commit homepage
path: root/lib/PublicInbox/Over.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/Over.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/Over.pm')
-rw-r--r--lib/PublicInbox/Over.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index cf7a8849..c74072a2 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -88,10 +88,12 @@ LIMIT 1
 SELECT * $cond
 ORDER BY ts ASC
 
+        return $msgs unless wantarray;
+
         my $nr = $dbh->selectrow_array(<<"", undef, $tid, $sid);
 SELECT COUNT(num) $cond
 
-        { total => $nr, msgs => $msgs };
+        ($nr, $msgs);
 }
 
 sub recent {
@@ -100,10 +102,12 @@ sub recent {
 SELECT * FROM over WHERE num > 0
 ORDER BY ts DESC
 
+        return $msgs unless wantarray;
+
         my $nr = $self->{dbh}->selectrow_array(<<'');
 SELECT COUNT(num) FROM over WHERE num > 0
 
-        { total => $nr, msgs => $msgs };
+        ($nr, $msgs);
 }
 
 sub get_art {