Slow Performance When Using DBI, otherwise Not



I have a Solaris 8 host running perl 5.8 and using DBI version 1.50 and
DBD::Oracle version 1.16. The database is Oracle 10.2.0.1 and runs on a
different host.

If I run this query from a shell script, it completes in under 1 second,
however, using a perl script it takes 5-10 seconds.

Here is the shell script:

#!/bin/bash

ORACLE_HOME=/u01/app/oracle/product/10.2
ORACLE_SID=mysid
SQLPLUS=/u01/app/oracle/product/10.2/bin/sqlplus

$SQLPLUS -s xxxxx/xxxxx@mysid << EOF
/ as sysdba
SELECT hostname from xxxxx.adc_ait_hosts where status > 0 order by hostname
asc;
quit;
EOF


Here is the perl code to do the same:

$ENV{ORACLE_HOME} = $_oracle_home;
$ENV{TWO_TASK} = $_oracle_two_task;
$ENV{TNS_ADMIN} = $_tns_admin;
my $ds = "dbi:Oracle:$_dbsid";
my $dbuser = $_dbuser;
my $dbpass = $_dbpass;

my @tapeservers;

my $dbh = DBI->connect($ds, $dbuser, $dbpass);

if (!defined($dbh)) {
print "Error: main(): database connection failed: $DBI::errstr\n";
cleanup();
exit(-1);
}

my $query1 = "SELECT hostname from xxxxx.adc_ait_hosts where status > 0
order by hostname asc ";
my $sth1 = $dbh->prepare($query1) || die "Error: Unable to prepare
query: $DBI::errstr\n";
$sth1->execute();

while ( my @row = $sth1->fetchrow_array)
{
if ($STRIP) {
my ($host, $subd, $domain, $sfx) = split(/\./, $row[0]);
print STDOUT "$host\n";
} else {
print STDOUT "$row[0]\n";
}
}


Can anyone point me in the right direction?

Thx,
CC


Relevant Pages

  • Re: file rename help
    ... Why, BTW? ... a shell script is a shell script and a Perl program is... ... what if $cfile was empty and hence moved to "$cfile.zero.txt"?!? ...
    (comp.lang.perl.misc)
  • Re: Scripting question, [small programming question
    ... at "rpm -ql util-linux". ... > comprehensive language like perl. ... I think a good rule of thumb is that if your shell script doesn't fit on a ...
    (Fedora)
  • [OT] Re: simple question on C++
    ... Jerry Stuart wrote: ... >> have something like this working today, I'd probably use Perl. ... I am familiar with Linux and would ... Well, on a typical Solaris system a shell script would do, and no reboot ...
    (alt.comp.lang.learn.c-cpp)
  • NEWBIE: Perls System -command and Cygwin bash-shell
    ... I am having problem in W2K when using Cygwin's Perl. ... My Perl script starts Shell script with System -command; ... cat "blah blah"> tempfile ... normal Bash shell command: "rm tempfile". ...
    (comp.lang.perl.misc)
  • RE: Run Shell Script Using Perl
    ... Run Shell Script Using Perl ... You need to rewrite a shell script that does file transfer in Perl? ... would work -- ftp, scp, rsync, cp over NFS mount (or SMB mount, or DAV ...
    (perl.beginners)