about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:51 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit77fe488ce5432a49ea8499605e0d8e155834575f (patch)
tree5e8a866a2d412e3c9014038fcad9f1df4bb10ad8
parent95da261efcf7c15b5e522344e207a3a04a374961 (diff)
downloadpublic-inbox-77fe488ce5432a49ea8499605e0d8e155834575f.tar.gz
over: get_art: use dbh->prepare_cached
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.
-rw-r--r--lib/PublicInbox/Over.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 402cbf7c..1faeff41 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 {