Re: Sending several commands simultaneously to PostgreSQL 8.4

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sending several commands simultaneously to PostgreSQL 8.4
Date: 2013-01-23 12:13:46
Message-ID: CAADeyWj4BCtmoQVz1o0VD2JSG-BEdzFZrMFp1qmnY-btOz0UfA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've ended up calling this procedure
in the loop before poll() - to run queued
commands from an array of hashes:

sub execSql {
eval {
my $dbh = DBI->connect_cached(DSN, DBUSER, DBPASS, {
private_key => __FILE__,
AutoCommit => 1,
PrintWarn => 1,
PrintError => 1,
RaiseError => 1,
FetchHashKeyName => 'NAME_lc',
pg_enable_utf8 => 1
});

if ($WaitSql && $dbh->pg_ready) {
$WaitSql = 0;
$dbh->pg_result();
}

if (!$WaitSql && @Sqls) {
$WaitSql = 1;
my $sql = shift @Sqls;
my $cmd = $sql->{CMD};
my $args = $sql->{ARGS};
my $sth = $dbh->prepare_cached($cmd,
{ pg_async => PG_ASYNC + PG_OLDQUERY_WAIT });
$sth->execute(@$args);
}
};
warn $@ if $@;
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2013-01-23 14:45:49 Re: Running update in chunks?
Previous Message Pavel Stehule 2013-01-23 12:13:18 Re: proposal: fix corner use case of variadic fuctions usage