From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 542CD1FBCA for ; Wed, 10 Jun 2020 07:07:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 54/82] over: get_art: use dbh->prepare_cached Date: Wed, 10 Jun 2020 07:04:51 +0000 Message-Id: <20200610070519.18252-55-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This speeds up xt/imapd-validate.t by around 10% when used with an abandoned patch to remove ->query_xover. We may also depend on this further if we abandon storing doc_data in Xapian to save disk space. --- lib/PublicInbox/Over.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index 402cbf7ce07..1faeff418f4 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -179,11 +179,12 @@ SELECT COUNT(num) FROM over WHERE num > 0 sub get_art { my ($self, $num) = @_; my $dbh = $self->connect; - my $smsg = $dbh->selectrow_hashref(<<'', undef, $num); + my $sth = $dbh->prepare_cached(<<'', undef, 1); SELECT num,ds,ts,ddd FROM over WHERE num = ? LIMIT 1 - return load_from_row($smsg) if $smsg; - undef; + $sth->execute($num); + my $smsg = $sth->fetchrow_hashref; + $smsg ? load_from_row($smsg) : undef; } sub next_by_mid {