diff options
author | Eric Wong <e@80x24.org> | 2021-07-23 10:56:11 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-07-25 00:11:36 +0000 |
commit | 1218bee34cf04498ac36add5c7e847698be541c2 (patch) | |
tree | 142afb972faffd2f01c1369cd1858cf36eb5b8ea /lib/PublicInbox/LeiSavedSearch.pm | |
parent | d15bd6a20a836473479d8431682ba305e2dcdfbe (diff) | |
download | public-inbox-1218bee34cf04498ac36add5c7e847698be541c2.tar.gz |
SQLite COUNT() is a slow operation that does a full table scan with no conditions. There's no need for it, since lei dedupe only needs to know if it's empty or not to decide between new/ and cur/ for Maildir outputs.
Diffstat (limited to 'lib/PublicInbox/LeiSavedSearch.pm')
-rw-r--r-- | lib/PublicInbox/LeiSavedSearch.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index 929380ed..cfbf68c3 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -315,11 +315,11 @@ E: rename($dir_old, $dir_new) error: $! EOM } -# cf. LeiDedupe->dedupe_nr -sub dedupe_nr { +# cf. LeiDedupe->has_entries +sub has_entries { my $oidx = $_[0]->{oidx} // die 'BUG: no {oidx}'; - my @n = $oidx->{dbh}->selectrow_array('SELECT COUNT(*) FROM over'); - $n[0]; + my @n = $oidx->{dbh}->selectrow_array('SELECT num FROM over LIMIT 1'); + scalar(@n) ? 1 : undef; } no warnings 'once'; |