Connection is to a MSSQL Server using DBI:sybase.

queries are the same, difference is one uses fetchrow_array() and the
other uses fetchrow_arrayref().

Supposedly, fetrow_arrayref() is faster than the other but doesn't seem
that way. 
(this is per Tim Bunce - Advanced DBI Tutorial July 2007)

Query obtained a total of ~70 columns. (output diverted to /dev/null)

Average of Actual Time  Process Time                    
Fetchtype               real    sys     user    Grand Total
aray                    5.3462  0.5484  3.128   3.007533333
arrayref                6.5944  0.878   2.696   3.389466667
Grand Total             5.9703  0.7132  2.912   3.1985


while ( $first = $sth->fetchrow_arrayref )
      {
      my $count = @$first;
      for (my $counter = 0; $counter < $count; $counter = $counter + 1)
        {
          if ($counter == $count-1)
          {
            if (defined($first->[$counter]))
            {
              print "\"$first->[$counter]\"";
            }
          } else {
            if (!defined($first->[$counter]))
            {
              print ",";
            } else {
              print "\"$first->[$counter]\",";
          }
        }
      }
print "\n";
      }

vs : 

while ( @first = $sth->fetchrow_array )
      {
      my $count = @first;

      for (my $counter = 0; $counter < $count; $counter = $counter + 1)
        {
          if ($counter == $count-1)
          {
            if (defined($first[$counter]))
            {
              print "\"$first[$counter]\"";
            }
          } else {
            if (!defined($first[$counter]))
            {
              print ",";
            } else {
              print "\"$first[$counter]\",";
          }
        }
      }
print "\n";
      }



Reply via email to