From 7c706ca3208b6f5be038fe31df46c90ff6846b97 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Thu, 10 May 2012 15:21:33 -0400 Subject: [PATCH] Cache the pg_typmod lookups. --- check_postgres.pl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index cc75dfd04..f575a21a6 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -7045,14 +7045,15 @@ sub find_catalog_info { ## For a function, we also want to put the args into the name if ($type eq 'function') { - ## Grab all type mappings - $SQL = 'SELECT oid, typname FROM pg_type'; - my %oid2type; - my $tinfo = run_command($SQL, { dbnumber => $dbnum }); - for my $row (@{ $tinfo->{db}[0]{slurp} }) { - $oid2type{$row->{oid}} = $row->{typname}; - } - (my $args = $row->{proargtypes}) =~ s/(\d+)/$oid2type{$1}||$1/ge; + ## Once per database, grab all mappings + if (! exists $opt{oid2type}{$dbnum}) { + $SQL = 'SELECT oid, typname FROM pg_type'; + my $tinfo = run_command($SQL, { dbnumber => $dbnum }); + for my $row (@{ $tinfo->{db}[0]{slurp} }) { + $opt{oid2type}{$dbnum}{$row->{oid}} = $row->{typname}; + } + } + (my $args = $row->{proargtypes}) =~ s/(\d+)/$opt{oid2type}{$dbnum}{$1}||$1/ge; $args =~ s/ /,/g; $args =~ s/ints/smallint/g; $args =~ s/int4/int/g; -- 2.39.5