develooper Front page | perl.dbi.users | Postings from January 2007

Re: out of memory

Thread Previous | Thread Next
From:
louis fridkis
Date:
January 2, 2007 08:22
Subject:
Re: out of memory
Message ID:
dcab49ed0701020822y3dbdb7f6p57a866d3764fb8@mail.gmail.com
Ron, Thanks again.

TIm, I am using psql.

On 12/30/06, Tim Bunce <Tim.Bunce@pobox.com> wrote:
>
> Assuming you're using mysql, take a look at the mysql_use_result
> attribute.
>
> Tim.
>
> On Thu, Dec 28, 2006 at 01:48:28PM -0800, louis fridkis wrote:
> > I am running out of memory when I try to select about 100K rows. Here is
> > some code:
> >
> > my $cel_sth = $dbh_from->prepare($sqlstring);
> > $cel_sth->execute();
> > my @rowvalues;
> > my $rv;
> > my $elementresult_id;
> > my $element_id;
> > my $quantification_id;
> > my $signal;
> >
> > $rv = $cel_sth->bind_columns(\($elementresult_id, $element_id,
> > $quantification_id, $signal));
> >
> > while($cel_sth->fetch()){
> >  @rowvalues = ($elementresult_id, $element_id, $quantification_id,
> > $signal);
> >  my $printstring= "insert into $table_name values(";
> >  foreach my $column (@rowvalues){
> >    if (defined $column){
> >      if($column =~ /\D/){
> >        $column = "'".$column."'"
> >          unless ($column =~ /\d*\.\d+/);
> >      }
> >      $printstring.= "$column,";
> >    } else {
> >      $printstring.= "NULL,";
> >    }
> >  }
> >  $printstring =~ s/,$/);/;
> >  print "$printstring\n";
> > }
> >
> > I guess the problem is it tries to hold all the rows in memory. Is there
> a
> > way to just get 1 or a few rows at a time?
> > --
> > Lou Fridkis
> > Human Genetics
> > 57920
>



-- 
Lou Fridkis
Human Genetics
57920

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About