Обсуждение: Pooling Connections with libpq

Поиск
Список
Период
Сортировка

Pooling Connections with libpq

От
Shaw Terwilliger
Дата:
In my application, I'm doing my own pooling of connections to PostgreSQL
for sharing between threads.  I'm using libpq for all database access.
Only one thread at a time can use a connection.

Besides freeing all query results, do I have to do anything else to ensure
my application (through libpq) and the backends don't leak RAM after long
periods of use?  I'm not using temporary tables, I'm only doing SELECTs on
these connections, reading, and then freeing the results.

--
Shaw Terwilliger <sterwill@sourcegear.com>
SourceGear Corporation
217.356.0105 x 641

Вложения

Re: Pooling Connections with libpq

От
Alfred Perlstein
Дата:
* Shaw Terwilliger <sterwill@sourcegear.com> [010222 14:42] wrote:
> In my application, I'm doing my own pooling of connections to PostgreSQL
> for sharing between threads.  I'm using libpq for all database access.
> Only one thread at a time can use a connection.
>
> Besides freeing all query results, do I have to do anything else to ensure
> my application (through libpq) and the backends don't leak RAM after long
> periods of use?  I'm not using temporary tables, I'm only doing SELECTs on
> these connections, reading, and then freeing the results.

As a general safety precaution I would close a connection after a
timeout or N uses.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]

Re: Pooling Connections with libpq

От
Shaw Terwilliger
Дата:
Alfred Perlstein wrote:
> As a general safety precaution I would close a connection after a
> timeout or N uses.

My application is running on the same host as PostgreSQL, so connection
timeouts should be rare (I guess this would only happen if a backend died).
Re-opening the connection after N uses sounds like a reasonable precaution
though.

(Hopefully my PGP signatures are correct this time.)

--
Shaw Terwilliger <sterwill@sourcegear.com>
SourceGear Corporation
217.356.0105 x 641

Вложения

Re: Pooling Connections with libpq

От
Alfred Perlstein
Дата:
* Shaw Terwilliger <sterwill@sourcegear.com> [010222 15:49] wrote:
> Alfred Perlstein wrote:
> > As a general safety precaution I would close a connection after a
> > timeout or N uses.
>
> My application is running on the same host as PostgreSQL, so connection
> timeouts should be rare (I guess this would only happen if a backend died).
> Re-opening the connection after N uses sounds like a reasonable precaution
> though.

I meant a user defined timeout, ie, a connection can only be recycled
100, 200 or 500 times (your choice) but can't be kept open for longer
than 5 minutes.

This is just for paranioa such that _if_ (there isn't as far as i
know) there's an issue with a backend leaking memory, you don't
get nailed by it.

> (Hopefully my PGP signatures are correct this time.)

PGP isn't really needed when having a general discussion .:)

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]