PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: ANNOUNCE: sybperl 2.08.50
Date: Oct 24 1997 10:11PM

This is a test release which includes serious performance improvements
over all the previous releases.

The connection attributes ($dbh->{UseDateTime}, etc) used to be 
stored in real perl hash, which, when -DDO_TIE was set, would call 
some perl code every time you access it. It is now emulated (stored in
a C struct) which improves speed tremedously (especially in DBlib which
makes heavy use of attributes).

dbnextrow() and ct_fetch() can now return a reference to a hash or an
array. This feature is enabled via a new $wantRef parameter to these
functions. The value of $wantRef defaults to false, to keep 
compatibility with any old scripts.

This also improves speed because I can pre-allocate the array on the
first fetch, and then simply set the values as required on each
subsequent fetch. This new featureThis means, however, that the
reference that is returned points to a 'static' array/hash, so you 
can't just use push() to store the reference in an array and get all 
the returned rows - you must make a copy of the array:

	while($d = $dbh->dbnextrow(0, 1)) {
		push(@rows, [ @$d ]);
	}

I know that this isn't perfect, but it's the same behaviour as when
returning arrays on the stack.

I've done a little benchmark to show the kind of speed improvements
that we can hope for:

========================
#!/usr/local/bin/perl

use Benchmark;
use Sybase::CTlib;

$t = new Benchmark;

my $dbh = new Sybase::CTlib 'sa';

print "$Sybase::CTlib::Version\n";

$dbh->ct_execute("select * from oncourse..resort");
$count = 0;
while($dbh->ct_results($restype) == CS_SUCCEED) {
    next if(!$dbh->ct_fetchable($restype));
    while($d = $dbh->ct_fetch(0,0)) {
	push(@x, $d);
	++$count;
    }
}

$t2 = new Benchmark;

print "Took: ", timestr(timediff($t2, $t)), " for $count rows\n";
==============

The table I'm selecting from has 30 columns (so it's fairly wide), and
I'm running this on a local Sybase server (10.1) on an Sparc Ultra 140.

kiruna (2:32pm):38 > perl benchct.pl 
This is sybperl, version 2.08_50

Sybase::CTlib version 1.28 10/24/97

Copyright (c) 1995-1997 Michael Peppler
Portions Copyright (c) 1995 Sybase, Inc.

Took: 16 secs (10.82 usr  0.27 sys = 11.09 cpu) for 20939 rows

kiruna (2:33pm):10 > perl Sybperl/benchct.pl
This is sybperl, version 2.08

Sybase::CTlib version 1.26 10/07/97

Copyright (c) 1995-1997 Michael Peppler
Portions Copyright (c) 1995 Sybase, Inc.

Took: 23 secs (17.20 usr  0.73 sys = 17.93 cpu) for 20939 rows
kiruna (2:33pm):11 > 

So here the new version takes 18 cpu seconds vs 11.1 for the new
version.

And the DBlibrary version of the same script:

kiruna (2:33pm):39 > perl benchdb.pl
This is sybperl, version 2.08_50

Sybase::DBlib version 1.37 10/24/97

Copyright (c) 1991-1997 Michael Peppler

Took: 17 secs (10.68 usr  0.49 sys = 11.17 cpu) for 20939 rows

kiruna (2:33pm):11 > perl Sybperl/benchdb.pl
This is sybperl, version 2.08

Sybase::DBlib version 1.35 10/07/97

Copyright (c) 1991-1997 Michael Peppler

Took: 35 secs (28.80 usr  0.84 sys = 29.64 cpu) for 20939 rows
kiruna (2:35pm):12 > 

Here it's 11.2 cpu seconds vs nearly 30 seconds. Both copies of sybperl
use the same libraries, and were compiled with the -DDO_TIE option set.


Now that I've got your attention... PLEASE test this version - do not
put in in production immediately - it IS a TEST release. If you have a 
little time and some resources I would be very grateful for feedback!

Thanks

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler