From 213e03e1f9624faa4a3a9813f1eac5035c1eb62a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 3 Aug 2022 20:03:55 +0000 Subject: miscidx: index inbox min/max article numbers This will be used to speed up NNTP group listings and IMAP startup with thousands of inboxes. --- lib/PublicInbox/Msgmap.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Msgmap.pm') diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index 1041cd17..cb4bb295 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -144,13 +144,17 @@ sub max { $sth->fetchrow_array // 0; } -sub minmax { - # breaking MIN and MAX into separate queries speeds up from 250ms - # to around 700us with 2.7million messages. +sub min { my $sth = $_[0]->{dbh}->prepare_cached('SELECT MIN(num) FROM msgmap', undef, 1); $sth->execute; - ($sth->fetchrow_array // 0, max($_[0])); + $sth->fetchrow_array // 0; +} + +sub minmax { + # breaking MIN and MAX into separate queries speeds up from 250ms + # to around 700us with 2.7million messages. + (min($_[0]), max($_[0])); } sub mid_delete { -- cgit v1.2.3-24-ge0c7