Re: max_prepared_transactions default ... why 5?

Lists: pgsql-hackers
From: Josh Berkus <josh(at)agliodbs(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: max_prepared_transactions default ... why 5?
Date: 2007-10-18 04:24:42
Message-ID: 200710172124.42386.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Folks,

I'm writing up the new GUCs, and noticed that max_prepared_transactions
defaults to 5. This is too many for most applications (which don't use them
at all) and far too few for applications which use them regularly.

It seems like we should either set the value to 0, or to something higher,
like 50.

It would also be nice to be able to just set the value to be equal to
max_connections automatically, but I'm sure I brought that point up too late.

--
Josh Berkus
PostgreSQL @ Sun
San Francisco


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 04:35:42
Message-ID: 16089.1192682142@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> I'm writing up the new GUCs, and noticed that max_prepared_transactions
> defaults to 5. This is too many for most applications (which don't use them
> at all) and far too few for applications which use them regularly.

I think the intention was to have enough so you could test 'em (in
particular, run the regression tests) without eating resources for
the majority of installations that aren't using them.

Certainly an installation that *is* using 'em would want a higher
setting.

regards, tom lane


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 04:49:01
Message-ID: 200710172149.01326.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wednesday 17 October 2007 21:35, Tom Lane wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
> > I'm writing up the new GUCs, and noticed that max_prepared_transactions
> > defaults to 5. This is too many for most applications (which don't use
> > them at all) and far too few for applications which use them regularly.
>
> I think the intention was to have enough so you could test 'em (in
> particular, run the regression tests) without eating resources for
> the majority of installations that aren't using them.
>
> Certainly an installation that *is* using 'em would want a higher
> setting.

Yeah, given the amount of memory per xact, I guess we can't actually set the
default higher. I just hate to see a setting that is liable to bite someone
on the tuchas so easily.

--
Josh Berkus
PostgreSQL @ Sun
San Francisco


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 05:00:34
Message-ID: 16349.1192683634@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> Yeah, given the amount of memory per xact, I guess we can't actually set the
> default higher. I just hate to see a setting that is liable to bite someone
> on the tuchas so easily.

I seem to recall thinking about replacing the setting with a
"prepared_transactions = on/off" boolean parameter, where "off" could be
defined as still allowing enough to run the regression tests. The
problem is to choose the "on" setting --- it's not too hard to think of
application behaviors where you need *more* than max_connections
entries.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 05:07:03
Message-ID: 200710180507.l9I573r15045@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus wrote:
> On Wednesday 17 October 2007 21:35, Tom Lane wrote:
> > Josh Berkus <josh(at)agliodbs(dot)com> writes:
> > > I'm writing up the new GUCs, and noticed that max_prepared_transactions
> > > defaults to 5. This is too many for most applications (which don't use
> > > them at all) and far too few for applications which use them regularly.
> >
> > I think the intention was to have enough so you could test 'em (in
> > particular, run the regression tests) without eating resources for
> > the majority of installations that aren't using them.
> >
> > Certainly an installation that *is* using 'em would want a higher
> > setting.
>
> Yeah, given the amount of memory per xact, I guess we can't actually set the
> default higher. I just hate to see a setting that is liable to bite someone
> on the tuchas so easily.

They will see the failure at 5 faster and adjust it accordingly. If it
was higher they might hit the limit only under heavy load and it would
surprise them.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Decibel! <decibel(at)decibel(dot)org>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 15:56:39
Message-ID: E31E089F-CBA2-45E1-A16C-40793657E3DD@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Oct 18, 2007, at 12:07 AM, Bruce Momjian wrote:
> Josh Berkus wrote:
>> On Wednesday 17 October 2007 21:35, Tom Lane wrote:
>>> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>>>> I'm writing up the new GUCs, and noticed that
>>>> max_prepared_transactions
>>>> defaults to 5. This is too many for most applications (which
>>>> don't use
>>>> them at all) and far too few for applications which use them
>>>> regularly.
>>>
>>> I think the intention was to have enough so you could test 'em (in
>>> particular, run the regression tests) without eating resources for
>>> the majority of installations that aren't using them.
>>>
>>> Certainly an installation that *is* using 'em would want a higher
>>> setting.
>>
>> Yeah, given the amount of memory per xact, I guess we can't
>> actually set the
>> default higher. I just hate to see a setting that is liable to
>> bite someone
>> on the tuchas so easily.
>
> They will see the failure at 5 faster and adjust it accordingly.
> If it
> was higher they might hit the limit only under heavy load and it would
> surprise them.

Actually, the amount of memory is a reason to default to 0, or change
the name, or put a big comment in the config, because I very often
saw databases where people had set this to a very high value under
the impression that it impacted prepared statements.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Decibel!" <decibel(at)decibel(dot)org>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Josh Berkus" <josh(at)agliodbs(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 16:23:47
Message-ID: 87ejfswfvw.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


"Decibel!" <decibel(at)decibel(dot)org> writes:

> Actually, the amount of memory is a reason to default to 0, or change the
> name, or put a big comment in the config, because I very often saw databases
> where people had set this to a very high value under the impression that it
> impacted prepared statements.

There's another cost associated with prepared transactions. If it's set to 0
then there's no real reason we need to wal log lock operations.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Decibel!" <decibel(at)decibel(dot)org>, "Gregory Stark" <stark(at)enterprisedb(dot)com>
Cc: "Josh Berkus" <josh(at)agliodbs(dot)com>, "Bruce Momjian" <bruce(at)momjian(dot)us>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 17:16:06
Message-ID: 47174E86.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>>> On Thu, Oct 18, 2007 at 11:23 AM, in message
<87ejfswfvw(dot)fsf(at)oxford(dot)xeocode(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>
wrote:

> If it's set to 0
> then there's no real reason we need to wal log lock operations.

Do we currently take advantage of that fact, or log them anyway?

-Kevin


From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Decibel!" <decibel(at)decibel(dot)org>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: max_prepared_transactions default ... why 5?
Date: 2007-10-18 17:45:02
Message-ID: 47179B9E.6080102@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Grittner wrote:
>>>> On Thu, Oct 18, 2007 at 11:23 AM, in message
> <87ejfswfvw(dot)fsf(at)oxford(dot)xeocode(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>
> wrote:
>
>> If it's set to 0
>> then there's no real reason we need to wal log lock operations.
>
> Do we currently take advantage of that fact, or log them anyway?

No, we log them anyway.

There's a few other reasons to WAL log lock operations, see comments in
heap_lock_tuple:

> /*
> * XLOG stuff. You might think that we don't need an XLOG record because
> * there is no state change worth restoring after a crash. You would be
> * wrong however: we have just written either a TransactionId or a
> * MultiXactId that may never have been seen on disk before, and we need
> * to make sure that there are XLOG entries covering those ID numbers.
> * Else the same IDs might be re-used after a crash, which would be
> * disastrous if this page made it to disk before the crash. Essentially
> * we have to enforce the WAL log-before-data rule even in this case.
> * (Also, in a PITR log-shipping or 2PC environment, we have to have XLOG
> * entries for everything anyway.)
> */

There's also the risk of torn pages. We set the xmax and the XMAX_*_LOCK
flag in heap_lock_tuple, and it's possible that only one of those
changes is written to disk before crash.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com