/usr/share/doc/libdbd-odbc-perl/examples/cancel_big_fetch.pl is in libdbd-odbc-perl 1.56-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #!/usr/bin/perl
# $Id$
# demonstrates that not fetching all of a result-set makes can make
# a difference. More recent MS SQL Server drivers are better at this so don't
# be surprised if this shows no difference between the 2 variations.
# However, in the past, cancelling a big select when you have not selected
# all rows has made a huge difference as MS SQL Server sees the cancel and
# stops sending the result-set.
use DBI;
use strict;
use warnings;
use Benchmark;
use Data::Dumper;
my $h = DBI->connect();
if (@ARGV) {
local $h->{PrintError} = 0;
eval {
$h->do(q/drop table mjebig/);
};
$h->do(q/create table mjebig(a varchar(255))/);
$h->begin_work; # quicker than autocommit
my $val = 'a' x 255;
my $s = $h->prepare(q/insert into mjebig values(?)/);
foreach (1..100000) {
$s->execute($val);
}
$h->commit;
}
sub one
{
my $s = $h->prepare(q/select * from mjebig/);
$s->execute;
$s->fetch;
$s = undef;
}
sub two
{
my $s = $h->prepare(q/select * from mjebig/);
$s->execute;
$s->fetch;
my $x = $s->cancel;
#print Dumper(\$x), "\n";
$s = undef;
}
timethese(1000, {
'without_cancel' => sub{one()},
'with_cancel' => sub{two()}
});
|