Re: DBI memory usage

[prev] [thread] [next] [Date index for 2005/01/18]

From: Peter Haworth
Subject: Re: DBI memory usage
Date: 10:43 on 18 Jan 2005
On Mon, 17 Jan 2005 17:46:17 -0800, Chris Ochs wrote:
> It looks like $r->child_terminate does what I need.  In the case of
> Postgresql it eats the memory when you execute the query, regardless
> of whether you actually fetch any results.

That can be worked around, however. By using a cursor, you can specify
exactly how much data you want at a time:

  $dbh->{AutoCommit}=0; # Cursors only work inside transactions
  $dbh->do(q(
    declare c cursor for
    -- YOUR SELECT GOES HERE
    for read only
  ));
  my $sth=$dbh->prepare('fetch forward 100 from c'); # Adjust number to taste
  do {
    $sth->execute;
    while(my $row=$sth->fetchrow_arrayref){
      # YOUR NORMAL LOOP BODY GOES HERE
    }
  } while $sth->rows+0; # It will be '0E0' (0 but true) the last time

        -- 
        	Peter Haworth	pmh@xxxxxx.xxxxxxxxxxxxx.xxx
"The trouble with emacs is that it is too big, and not everywhere.
 Also, it keeps adding :wq! to the end of all my documents."
		-- Redvers Davies

(message missing)

DBI memory usage
Chris Ochs 01:06 on 18 Jan 2005

Re: DBI memory usage
Perrin Harkins 01:18 on 18 Jan 2005

Re: DBI memory usage
Perrin Harkins 01:23 on 18 Jan 2005

Re: DBI memory usage
Chris Ochs 01:46 on 18 Jan 2005

Re: DBI memory usage
Peter Haworth 10:43 on 18 Jan 2005

Re: DBI memory usage
Chris Ochs 18:12 on 18 Jan 2005

Re: DBI memory usage
Peter Haworth 11:12 on 19 Jan 2005

Re: DBI memory usage
Steven Lembark 04:26 on 18 Jan 2005

Re: DBI memory usage
Chris Ochs 04:44 on 18 Jan 2005

Re: DBI memory usage
Sean Davis 11:03 on 18 Jan 2005

Re: DBI memory usage
Fred Moyer 21:10 on 18 Jan 2005

Re: DBI memory usage
Fred Moyer 21:11 on 18 Jan 2005

RE: DBI memory usage
Theo Petersen 15:51 on 19 Jan 2005

Generated at 17:42 on 27 Jan 2005 by mariachi v0.52