Re: High memory usage with savepoints & encoding differences

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dylan Adams" <dadams(at)bybaxter(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: High memory usage with savepoints & encoding differences
Date: 2009-04-18 00:03:48
Message-ID: 1762.1240013028@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Dylan Adams" <dadams(at)bybaxter(dot)com> writes:
> I'm running into a situation where postmaster is consuming significantly
> more memory than I would expect. This only seems to happen when I
> combine savepoints with differences between client and database
> encoding. I originally discovered this while running some Java code
> which uses JDBC (the postgres JDBC driver always sets client_encoding to
> UNICODE) to connect to a latin1 encoded database, but it's reproducible
> with psql as well.

I think this example is pretty artificial. The fundamental reason
memory is increasing is that each subtransaction can require some state
storage. In the example the per-subtransaction CurTransactionContexts
are not getting used for anything except encoding conversion on the
SAVEPOINT/RELEASE command completion messages --- but if you were doing
any real work in the subtransactions then most likely there would be
additional stuff there, so I'm not excited about trying to suppress
this particular symptom.

The bottom line is that lots and lots of subtransactions isn't a very
good thing for performance, especially with a couple of network round
trips for each one. Consider pushing whatever work is involved here
into a server-side function.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dylan Adams 2009-04-18 01:06:55 Re: High memory usage with savepoints & encoding differences
Previous Message Grzegorz Jaskiewicz 2009-04-17 23:39:41 Re: [GENERAL] Performance of full outer join in 8.3