diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-02 00:04:55 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-02 00:05:42 +0000 |
commit | 87dca6d8d5988c5eb54019cca342450b0b7dd6b7 (patch) | |
tree | a415a88759b88014d30544addbb69c5949ed76f0 /lib/PublicInbox/Feed.pm | |
parent | 3cc5ff405d9054fbf47ac44774fca4f9a72ff65a (diff) | |
download | public-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/Feed.pm')
-rw-r--r-- | lib/PublicInbox/Feed.pm | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 2f59f8c2..ff20d7fa 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -27,14 +27,13 @@ sub generate { sub generate_thread_atom { my ($ctx) = @_; my $mid = $ctx->{mid}; - my $res = $ctx->{srch}->get_thread($mid); - return _no_thread() unless $res->{total}; + my $msgs = $ctx->{srch}->get_thread($mid); + return _no_thread() unless @$msgs; my $ibx = $ctx->{-inbox}; my $html_url = $ibx->base_url($ctx->{env}); $html_url .= PublicInbox::Hval->new_msgid($mid)->{href}; $ctx->{-html_url} = $html_url; - my $msgs = $res->{msgs}; PublicInbox::WwwAtomStream->response($ctx, 200, sub { while (my $smsg = shift @$msgs) { $ibx->smsg_mime($smsg) and return $smsg; @@ -114,10 +113,10 @@ sub recent_msgs { my $o = $qp ? $qp->{o} : 0; $o += 0; $o = 0 if $o < 0; - my $res = $ibx->recent({ limit => $max, offset => $o }); + my $msgs = $ibx->recent({ limit => $max, offset => $o }); my $next = $o + $max; - $ctx->{next_page} = "o=$next" if $res->{total} >= $next; - return $res->{msgs}; + $ctx->{next_page} = "o=$next" if scalar(@$msgs) == $max; + return $msgs; } my $hex = '[a-f0-9]'; |