about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.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/View.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/View.pm')
-rw-r--r--lib/PublicInbox/View.pm17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 8ac405f2..cad90a79 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -408,9 +408,7 @@ sub thread_html {
         my ($ctx) = @_;
         my $mid = $ctx->{mid};
         my $srch = $ctx->{srch};
-        my $sres = $srch->get_thread($mid);
-        my $msgs = $sres->{msgs};
-        my $nr = $sres->{total};
+        my ($nr, $msgs) = $srch->get_thread($mid);
         return missing_thread($ctx) if $nr == 0;
         my $skel = '<hr><pre>';
         $skel .= $nr == 1 ? 'only message in thread' : 'end of thread';
@@ -649,8 +647,7 @@ sub thread_skel {
         my ($dst, $ctx, $hdr, $tpfx) = @_;
         my $srch = $ctx->{srch};
         my $mid = mids($hdr)->[0];
-        my $sres = $srch->get_thread($mid);
-        my $nr = $sres->{total};
+        my ($nr, $msgs) = $srch->get_thread($mid);
         my $expand = qq(expand[<a\nhref="${tpfx}T/#u">flat</a>) .
                         qq(|<a\nhref="${tpfx}t/#u">nested</a>]  ) .
                         qq(<a\nhref="${tpfx}t.mbox.gz">mbox.gz</a>  ) .
@@ -680,12 +677,11 @@ sub thread_skel {
         $ctx->{prev_attr} = '';
         $ctx->{prev_level} = 0;
         $ctx->{dst} = $dst;
-        $sres = $sres->{msgs};
 
         # reduce hash lookups in skel_dump
         my $ibx = $ctx->{-inbox};
         $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
-        walk_thread(thread_results($ctx, $sres), $ctx, *skel_dump);
+        walk_thread(thread_results($ctx, $msgs), $ctx, *skel_dump);
 
         $ctx->{parent_msg} = $parent;
 }
@@ -1066,11 +1062,10 @@ sub index_topics {
 
         $ctx->{order} = [];
         my $srch = $ctx->{srch};
-        my $sres = $ctx->{-inbox}->recent({offset => $off, limit => 200 });
-        $sres = $sres->{msgs};
-        my $nr = scalar @$sres;
+        my $msgs = $ctx->{-inbox}->recent({offset => $off, limit => 200 });
+        my $nr = scalar @$msgs;
         if ($nr) {
-                walk_thread(thread_results($ctx, $sres), $ctx, *acc_topic);
+                walk_thread(thread_results($ctx, $msgs), $ctx, *acc_topic);
         }
         $ctx->{-next_o} = $off + $nr;
         $ctx->{-cur_o} = $off;