DCOracle2 performance tuning

Stacy White harsh at computer.org
Sat Nov 23 14:17:15 EST 2002


I work with a large body of Perl code, and am toying around with the
possibility of converting to Python.  One thing standing in my way is my
inability to make DCOracle2 perform comparably to Perl's DBD::Oracle.

DCOracle2 performance is good relative to DBD::Oracle until it's faced with
large result sets.  For instance, time for:

  c = db.cursor()
  c.execute("select one_field from table_with_10000_rows")
  r = c.fetchone()
  while r:
      r = c.fetchone()

is

  0.620u 0.030s 0:00.75 86.6%     0+0k 0+0io 1193pf+0w

vs.

  my $sth = $dbh->prepare("SELECT one_field from table_with_10000_rows");
  $sth->execute();
  while (my $data = $sth->fetchrow_arrayref) {
  }

at

  0.480u 0.040s 0:00.62 83.8%     0+0k 0+0io 1211pf+0w

So not quite as fast, but still acceptable (about 0.12s in either case is
due to login time, so the Python code takes about 25% longer, but that's not
too big a deal).

But changing the execute line to select all 50 fields from the table:

   c.execute("select * from table_with_10000_rows")

changes the Python time to:

  10.780u 0.120s 0:10.74 101.4%   0+0k 0+0io 5549pf+0w

vs. a Perl time of:

  1.960u 0.060s 0:02.18 92.6%     0+0k 0+0io 1218pf+0w

I've fiddled around with fetchmany, and fetchall with no luck.  For example,
changing the inner loop to:

    rows = c.fetchmany(20)
    while len(rows):
        for r in rows:
            pass
        rows = c.fetchmany(20)

leaves me with the same performance.

Any suggestions?





More information about the Python-list mailing list