On Wed, Aug 16, 2000 at 08:26:09AM +0200, Henrik Tougaard wrote:
> From: Jay Jacobs [mailto:[EMAIL PROTECTED]]
> > On Tue, 15 Aug 2000, Tom Mornini wrote:
> > 
> > > It is my understanding of the DBI docs that you only need to call
> > > $sth->finish when you DON'T fetch all the rows that the 
> > $sth has ready to
> > > return.
> > > 
> > 
> > From "Writing Apache Modules with Perl and C":
> >   "You should still call finish() at the end of each series 
> > of fetches,
> > even though you are going to reuse the statement handler.  
> > Failure to do
> > so can lead to memory leaks."
> > 
> 
> You picked the wrong authority for this! The right place (tm) to look 
> when discussing DBI is 'perldoc DBI'. The relevant quote is:

> > If I remember correctly, it also frees up any resources used by the
> > database (depending on db) for the query, like for sorting, joining,
> > etc.  But I can't quote a source for that one.
>
> There is no authoritative source for that fallacy - I hope!

The right place (tm) to look when discussing DBI is 'perldoc DBI'. The
relevant quote is:

     $rc  = $sth->finish;
   
   [...]
   
   Consider a query like:
   
     SELECT foo FROM table WHERE bar=? ORDER BY foo
   
   where you want to select just the first (smallest) "foo" value from a
   very large table. When executed, the database server will have to use
   temporary buffer space to store the sorted rows. If, after executing
   the handle and selecting one row, the handle won't be re-executed for
   some time and won't be destroyed, the C<finish> method can be used to tell
   the server that the buffer space can be freed.

:-)

Tim.

Reply via email to