use lib qw ( c:/perlmodules ); use SqlSupport; my $dbh = connectpgdb(*,*,*,*,*); my $query = "select id,post from blog where language = 'en'"; my $sth = $dbh->prepare($query); $sth->execute || die "Could not execute MySQL statement: $sqlstatement"; my $rows = []; # cache for batches of rows while( my $row = ( shift(@$rows) || shift(@{$rows=$sth->fetchall_arrayref(undef,10_000) || []}))) { my $foo = 1; } $sth->finish();