经过一些更新(系统和brew - 我不知道哪个原因)后,Perl 的 DBD:Pg 建立与本地 Postgresql 实例的连接速度很慢。连接建立后执行查询并不慢。没有其他实用程序或驱动程序(psql、jdbc、.NET)的连接速度较慢。
此代码创建到本地 postgres 实例的连接:
#!/usr/bin/env perl
use strict;
use DBI;
use DBD::Pg;
use Carp;
my $appname = "test-connect";
my $host = "127.0.0.1";
my $port = "5432";
my $dbname = "postgres";
my $dbuser = "postgres";
my $password = "";
my $sslmode = "disable";
carp( "************* - DBI trace settings (before)= " . (DBI->trace() // '(none)'));
DBI->trace(DBD::Pg->parse_trace_flag('pglibpq'));
carp( "************* - DBI trace settings (after)= " . (DBI->trace() // '(none)'));
# Create the connection
carp("************* - …Run Code Online (Sandbox Code Playgroud)