On Mon, 15 May 2000, Ken Y. Clark wrote:
> On Mon, 15 May 2000, Jeffrey W. Baker wrote:
>
> > On Mon, 15 May 2000, Jay Jacobs wrote:
> >
> > > I've been reading over the guide on "Efficient Work with Databases under
> > > mod_perl" and there's one thing I don't quite grok about it. Let's say I
> > > have a site that goes through select statements like water. If I were to
> > > cache the statement handler (as described in the guide), how does the
> > > database (database dependant) handle a bunch of dangling statement
> > > handlers? Will the database process size grow a ton? I'm not sure if I'm
> > > hitting what I wanted to ask, but hopefully I'm close enough.
> >
> > Every statement handle that you leave open will consume resources on the
> > database server, and also on the client side. These resources are
> > presumed to be more plentiful than the resources (CPU time and network
> > packets) needed to frequently setup and teardown statement handles.
>
> if this behavior is unacceptable, i believe you can use the finish method:
>
> finish
>
> $rc = $sth->finish;
>
> Indicates that no more data will be fetched from this
> statement handle before it is either executed again or
> destroyed. It is rarely needed but can sometimes be
> helpful in very specific situations in order to allow
> the server to free up resources currently being held
> (such as sort buffers).
>
> (from perldoc DBI)
That's true, and the RDBMS would be free to release any buffers associated
with unfetched rows in that case. However, you are still consuming
server-side resources with every handle that remains open. At the very
least, you are consuming memory on the order of sizeof(struct
statement) or whatever.
-jwb