my $sth = $dbn -> prepare("select number,id,start_dat,end_dat from SUBSCRIBERSLIST"); $sth -> execute(); $sth->bind_columns(\$number, \$id,\$start_dat,\$end_dat); my $max_row=5000; my $rowcache; my %hash =(); while (my $aref = shift(@$rowcache) || shift ( @{$rowcache= $sth->fetchall_arrayref(undef, $max_rows)} ) ) { # $aref now contains only one row push @{$hash{$aref[0]}}, [ $aref[1],$aref[2],$aref[3] ]; }; $sth->finish(); $dbn->disconnect;