Posted by Chung Leong on 04/30/07 22:58
On Apr 30, 8:08 pm, Sanders Kaufman <b...@kaufman.net> wrote:
> Chung Leong wrote:
> > As a side note: Don't wait till the end of the page before you close
> > the database connection. That's a recipe for "Too many connections"
> > errors. Read the necessary data from the database then close the
> > connection before you output to the client.
>
> Could you expand on that?
> I can't think of a way that closing at the end would do that.
Well, it's not that hard to understand. It takes time for the page to
get sent to the client. Generally it's a lot longer than the time it
takes to retrieve data from the database. A query might take 100
millisec. Transferring a HTML page could conceivably take over 10
seconds. Holding onto the connection til the end of the page means
more concurrent connection there needs to be.
Navigation:
[Reply to this message]
|