From: Greg Sabino Mullane Date: Thu, 10 May 2012 19:21:33 +0000 (-0400) Subject: Cache the pg_typmod lookups. X-Git-Tag: 2.20.0~36 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=7c706ca3208b6f5be038fe31df46c90ff6846b97;p=check_postgres.git Cache the pg_typmod lookups. --- 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;