Re: Do we still need constraint_exclusion?

Lists: pgsql-hackers
From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Greg Smith <gsmith(at)gregsmith(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Do we still need constraint_exclusion?
Date: 2009-01-07 05:15:48
Message-ID: 200901070515.n075Fmi27660@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Based on the comments below, are we sure constraint_exclusion still
needs to be a parameter and can't be on by default?

---------------------------------------------------------------------------

Greg Smith wrote:
> On Thu, 4 Dec 2008, Gregory Stark wrote:
>
> > Greg Smith <gsmith(at)gregsmith(dot)com> writes:
> >
> >> Is it worse to suffer from additional query overhead if you're sloppy with
> >> the tuning tool, or to discover addition partitions didn't work as you
> >> expected?
> >
> > Surely that's the same question we faced when deciding what the Postgres
> > default should be?
>
> Gosh, you're right. I'm really new here, and I just didn't understand how
> things work. I should have known that there was lots of thorough research
> into that setting before the default was set. (hangs head in shame)
>
> Wait, what list am I on? pgsql-hackers? Oh, crap, that can't be right at
> all then. This one is actually an interesting example of how this stuff
> ends up ossified without being revisited, I'm glad you brought it up.
>
> First we have to visit the 8.1 and 8.2 documentation. There we find the
> real reason it originally defaulted to off:
>
> http://www.postgresql.org/docs/8.1/static/runtime-config-query.html
> "Currently, constraint_exclusion is disabled by default because it risks
> incorrect results if query plans are cached if a table constraint is
> changed or dropped, the previously generated plan might now be wrong, and
> there is no built-in mechanism to force re-planning." It stayed off for
> that reason for years.
>
> Then the plan invalidation stuff went into 8.3 that made this no longer
> true. Bruce even removed the item from the TODO list that used to say
> that constraint_exclusion should be improved to "allow it to be used for
> all statements with little performance impact". Then a couple of months
> later, when the 8.3 docs were being worked on, Tom updated the text to
> remove the obsolete warning about the plan risks:
>
> http://archives.postgresql.org/pgsql-committers/2007-03/msg00372.php
>
> Leaving only the leftovers of the original caveat about how it can also
> cause some overhead as the reason for why it was still off--a concern
> which was certainly more serious when that text was written in 2005 than
> it is today for multiple reasons.
>
> How much was that overhead lowered by the work done in 8.3? I can't find
> any public information suggesting that was ever even discussed. The only
> thing I found when poking around looking for it is that Tom had expressed
> some concerns that the proof overhead was too still large back in 2006:
> http://archives.postgresql.org/pgsql-committers/2006-02/msg00035.php
>
> But you know what? The cached proof comparison bit Tom commited a couple
> of weeks ago shifted the mechanics of the overhead for this specific case
> around, so even if we did have 8.3 results they'd need to get re-run at
> this point anyway. See below for more on what might be different soon.
>
> So, if you want to say that turning on constraint_exclusion by default is
> a horrible idea because it adds significant overhead, and you have any
> sort of evidence that will still be true for 8.4 on the kind of hardware
> 8.4 is likely to run on, I would greatly appreciate that information.
>
> But presuming that serious thought must have went into every decision made
> about what the defaults for all the performance-related parameter in the
> postgresql.conf is something we all know just ain't so. What I see is a
> parameter that doesn't add enough overhead relative to query execution
> time on today's systems that I've noticed whether it was on or off, one
> that's set to off only by historical accident combined with basic
> conservatism (mainly from Tom far as I can tell, he's a nice reliable
> source for that). Whereas if it's accidentally set wrong, it can lead to
> massively wrong plans. I'm not sure what the right move here is, but the
> appeal to authority approach for defending the default here isn't going to
> work on me.
>
> > That and the unstated other question "Is someone more likely to use partitions
> > without reading the manual or not use partitions without reading the manual
> > about the down-sides of constraint_exclusion (in the partitioning
> > section....)"
>
> Have you started thinking about the implications of
> http://archives.postgresql.org/message-id/a301bfd90810310750pf108c69x36499546f406650f@mail.gmail.com
> yet? It is a bold new world of people who partition with less time stuck
> in the manual first we approach, and I was very much thinking about that
> when mulling over whether I agreed with Josh's suggestion to put that into
> the default mixed settings before I went with it (that's right--I wrote
> all the above and it wasn't even my idea originally). If that doesn't
> make it into 8.4 I will yield to your statement of the boring,
> manual-reading status quo still being on target.
>
> --
> * Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

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

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


From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 12:04:35
Message-ID: 603c8f070901070404h66b7e608iaae70a06c126376f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 7, 2009 at 12:15 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Based on the comments below, are we sure constraint_exclusion still
> needs to be a parameter and can't be on by default?

The benchmarking we did to determine the impact of raising
default_statistics_target was pretty interesting and informative. It
seems like a similar approach would be valuable here, though I'm not
exactly sure what to test.

...Robert


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 13:39:42
Message-ID: 20090107133942.GN26233@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Bruce Momjian (bruce(at)momjian(dot)us) wrote:
> Based on the comments below, are we sure constraint_exclusion still
> needs to be a parameter and can't be on by default?

I'd like to get rid of the option and have it on by default. It's a bit
frustrating to have to remember to turn it on with new installs, and if
it doesn't add much overhead or cause problems then I don't see the
value in having it be configurable.

Thanks,

Stephen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 15:59:51
Message-ID: 28841.1231343991@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
> On Wed, Jan 7, 2009 at 12:15 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> Based on the comments below, are we sure constraint_exclusion still
>> needs to be a parameter and can't be on by default?

> The benchmarking we did to determine the impact of raising
> default_statistics_target was pretty interesting and informative.

Here's a quick and dirty benchmark. I put 10000 copies of
select count(*) from tenk1 where thousand = 42;
into a file and executed
time psql -q -f z10000.sql regression >/dev/null
several times (just to check how much noise there was in the results).
This is this morning's CVS HEAD, debug/cassert enabled, default
configuration parameters except for turning off autovacuum to reduce
the noise.

Stock table definition (ie, no constraints)

c_e off

real 0m7.828s
real 0m8.051s
real 0m7.871s
real 0m7.960s
total: 31.710 sec

c_e on

real 0m7.991s
real 0m8.149s
real 0m7.905s
real 0m7.910s
total: 31.955 sec

then
alter table tenk1 add constraint c1 check (thousand between 0 and 1000);

c_e off

real 0m7.868s
real 0m8.061s
real 0m7.759s
real 0m7.988s
total: 31.676 sec

c_e on

real 0m8.601s
real 0m8.551s
real 0m8.571s
real 0m8.772s
total: 34.495

then
alter table tenk1 add constraint c2 check (tenthous between 0 and 10000);

c_e off

real 0m7.922s
real 0m7.936s
real 0m7.901s
real 0m7.866s
total: 31.625 sec

c_e on

real 0m8.723s
real 0m8.865s
real 0m8.838s
real 0m8.747s
total: 35.173 sec

The measured difference between CE off and CE on without any actual
constraints to test is less than 1%, and it's not clear that that's
above the noise threshold in this test. But the penalty when there is
a relevant constraint is very measurable (about 9% here) and even a
constraint that is not relevant to the query takes a measurable amount
of time to discard (about 2% here). Again note that these are overall
numbers using a psql script; an application with less per-query overhead
would see worse degradation.

In installations whose average query is significantly heavier-weight
than this one, and where constraint exclusion actually improves matters
on a routine basis, it makes sense to turn it on by default. I will
continue to resist having it on as a factory default, because I continue
to believe that it's 99% useless to most people. As for removing the
option, no way.

regards, tom lane


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 16:56:35
Message-ID: 1231347395.12947.28.camel@jd-laptop.pragmaticzealot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2009-01-07 at 10:59 -0500, Tom Lane wrote:
> "Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
> > On Wed, Jan 7, 2009 at 12:15 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> >> Based on the comments below, are we sure constraint_exclusion still
> >> needs to be a parameter and can't be on by default?

> In installations whose average query is significantly heavier-weight
> than this one, and where constraint exclusion actually improves matters
> on a routine basis, it makes sense to turn it on by default. I will
> continue to resist having it on as a factory default, because I continue
> to believe that it's 99% useless to most people. As for removing the

I believe are correct in that it is 99% useless to most people. If it
was turned on by default, it would also not be noticed by 99% of those
people.

So why not help the 1% that it actually would?

Joshua D. Drake

> regards, tom lane
>
--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jd(at)commandprompt(dot)com
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:19:15
Message-ID: 4859.1231348755@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> On Wed, 2009-01-07 at 10:59 -0500, Tom Lane wrote:
>> In installations whose average query is significantly heavier-weight
>> than this one, and where constraint exclusion actually improves matters
>> on a routine basis, it makes sense to turn it on by default. I will
>> continue to resist having it on as a factory default, because I continue
>> to believe that it's 99% useless to most people. As for removing the

> I believe are correct in that it is 99% useless to most people. If it
> was turned on by default, it would also not be noticed by 99% of those
> people.

~ 10% slowdown on trivial queries will get noticed.

I just thought of a possible compromise though: maybe we could invent an
intermediate constraint_exclusion setting that makes the checks only for
inheritance-child tables. This would avoid the overhead for simple
queries and still get the benefit for most of the cases where it's
actually useful. I'm not sure how hard this'd be to shoehorn into the
planner, but if it's doable it might satisfy both camps.

regards, tom lane


From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, "Bruce Momjian" <bruce(at)momjian(dot)us>, "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:26:32
Message-ID: 603c8f070901070926l4ff6661fw1011303c93b9a253@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> ~ 10% slowdown on trivial queries will get noticed.

Agreed.

> I just thought of a possible compromise though: maybe we could invent an
> intermediate constraint_exclusion setting that makes the checks only for
> inheritance-child tables. This would avoid the overhead for simple
> queries and still get the benefit for most of the cases where it's
> actually useful. I'm not sure how hard this'd be to shoehorn into the
> planner, but if it's doable it might satisfy both camps.

+1

...Robert


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:35:24
Message-ID: 1231349724.12947.42.camel@jd-laptop.pragmaticzealot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2009-01-07 at 12:26 -0500, Robert Haas wrote:
> > ~ 10% slowdown on trivial queries will get noticed.

> > I just thought of a possible compromise though: maybe we could invent an
> > intermediate constraint_exclusion setting that makes the checks only for
> > inheritance-child tables. This would avoid the overhead for simple
> > queries and still get the benefit for most of the cases where it's
> > actually useful. I'm not sure how hard this'd be to shoehorn into the
> > planner, but if it's doable it might satisfy both camps.

I can buy into this.

Joshua D. Drake

>
> +1
>
> ...Robert
>
--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:54:35
Message-ID: 13476.1231350875@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> I just thought of a possible compromise though: maybe we could invent an
> intermediate constraint_exclusion setting that makes the checks only for
> inheritance-child tables. This would avoid the overhead for simple
> queries and still get the benefit for most of the cases where it's
> actually useful. I'm not sure how hard this'd be to shoehorn into the
> planner, ...

Actually, it looks like it'd be totally trivial to implement: just check
rel->reloptkind == RELOPT_OTHER_MEMBER_REL to detect whether we're
looking at an inheritance child. (Actually this would also succeed
for a UNION ALL member, but that's good because that's the other case
where constraint exclusion is more likely to be useful.)

So, barring objections, I'll go make this happen. What do we want to
call the intermediate constraint_exclusion value? The first thing
that comes to mind is constraint_exclusion = 'child', but perhaps
someone has a better idea.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:58:48
Message-ID: 200901071758.n07Hwm315449@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> I wrote:
> > I just thought of a possible compromise though: maybe we could invent an
> > intermediate constraint_exclusion setting that makes the checks only for
> > inheritance-child tables. This would avoid the overhead for simple
> > queries and still get the benefit for most of the cases where it's
> > actually useful. I'm not sure how hard this'd be to shoehorn into the
> > planner, ...
>
> Actually, it looks like it'd be totally trivial to implement: just check
> rel->reloptkind == RELOPT_OTHER_MEMBER_REL to detect whether we're
> looking at an inheritance child. (Actually this would also succeed
> for a UNION ALL member, but that's good because that's the other case
> where constraint exclusion is more likely to be useful.)
>
> So, barring objections, I'll go make this happen. What do we want to
> call the intermediate constraint_exclusion value? The first thing
> that comes to mind is constraint_exclusion = 'child', but perhaps
> someone has a better idea.

Wow, this will be a great leap forward for usability.

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

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


From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, "Bruce Momjian" <bruce(at)momjian(dot)us>, "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 17:59:17
Message-ID: 603c8f070901070959g4732d320qd547682b0ab374a2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> So, barring objections, I'll go make this happen. What do we want to
> call the intermediate constraint_exclusion value? The first thing
> that comes to mind is constraint_exclusion = 'child', but perhaps
> someone has a better idea.

"inherit"?

...Robert


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:15:59
Message-ID: 20090107181559.GP26233@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Actually, it looks like it'd be totally trivial to implement: just check
> rel->reloptkind == RELOPT_OTHER_MEMBER_REL to detect whether we're
> looking at an inheritance child. (Actually this would also succeed
> for a UNION ALL member, but that's good because that's the other case
> where constraint exclusion is more likely to be useful.)

Covering the UNION ALL case would be terrific! I was a bit concerned
since we just have UNION ALL views and don't use inheritance generally.

> So, barring objections, I'll go make this happen. What do we want to
> call the intermediate constraint_exclusion value? The first thing
> that comes to mind is constraint_exclusion = 'child', but perhaps
> someone has a better idea.

Not a huge fan of 'child' since it implies inheritance. 'union' doesn't
work for a similar reason. What about 'partitioned'?

Thanks,

Stephen


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:32:37
Message-ID: 4964F545.2030802@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> So, barring objections, I'll go make this happen. What do we want to
> call the intermediate constraint_exclusion value? The first thing
> that comes to mind is constraint_exclusion = 'child', but perhaps
> someone has a better idea.

This is terrific. I've actually been turning c_e on and off by ROLE
property at some sites because of the penalty on one-liner web queries.
This would solve that.

I don't like "child", though, which is not a keyword we use definitively
elsewhere. I'd suggest "INHERITED" or something based on "inherit",
because that's the actual keyword we use when we create a partition.

--Josh


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:36:35
Message-ID: 26463.1231353395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephen Frost <sfrost(at)snowman(dot)net> writes:
> * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
>> So, barring objections, I'll go make this happen. What do we want to
>> call the intermediate constraint_exclusion value? The first thing
>> that comes to mind is constraint_exclusion = 'child', but perhaps
>> someone has a better idea.

> Not a huge fan of 'child' since it implies inheritance. 'union' doesn't
> work for a similar reason. What about 'partitioned'?

Hm, how about just 'partition'? Your argument is fair, and another
point in its favor is that someday we'll probably have an explicit
notion of partitioned tables and both the inheritance and union-view
approaches would become legacy methods. We'd certainly want constraint
exclusion to apply to all three by default.

regards, tom lane


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:40:01
Message-ID: 4964F701.1080402@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom,

> Hm, how about just 'partition'? Your argument is fair, and another
> point in its favor is that someday we'll probably have an explicit
> notion of partitioned tables and both the inheritance and union-view
> approaches would become legacy methods. We'd certainly want constraint
> exclusion to apply to all three by default.

I think that's probably the best compromise.

--Josh


From: Zeugswetter Andreas OSB sIT <Andreas(dot)Zeugswetter(at)s-itsolutions(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>
Cc: "jd(at)commandprompt(dot)com" <jd(at)commandprompt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:42:40
Message-ID: 6DAFE8F5425AB84DB3FCA4537D829A561CEA8AA8F9@M0164.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> >> So, barring objections, I'll go make this happen. What do we want to
> >> call the intermediate constraint_exclusion value? The first thing
> >> that comes to mind is constraint_exclusion = 'child', but perhaps
> >> someone has a better idea.
>
> > Not a huge fan of 'child' since it implies inheritance. 'union' doesn't
> > work for a similar reason. What about 'partitioned'?
>
> Hm, how about just 'partition'?

+1

Andreas


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 18:57:17
Message-ID: 20090107185717.GQ26233@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Hm, how about just 'partition'? Your argument is fair, and another
> point in its favor is that someday we'll probably have an explicit
> notion of partitioned tables and both the inheritance and union-view
> approaches would become legacy methods. We'd certainly want constraint
> exclusion to apply to all three by default.

'partition' works for me.

Thanks!

Stephen


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 21:21:33
Message-ID: 1231363293.18005.74.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Wed, 2009-01-07 at 12:54 -0500, Tom Lane wrote:

> So, barring objections, I'll go make this happen.

I don't really understand this. Who can set up an inherited table
structure but can't remember to turn on constraint_exclusion? That is
the easiest part of the whole process by a long way. Nobody has this
table design by accident, they've all been told how or read the docs.

I'm not against the change so much as bemused by it.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 21:24:37
Message-ID: 200901072124.n07LObE18178@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
>
> On Wed, 2009-01-07 at 12:54 -0500, Tom Lane wrote:
>
> > So, barring objections, I'll go make this happen.
>
> I don't really understand this. Who can set up an inherited table
> structure but can't remember to turn on constraint_exclusion? That is
> the easiest part of the whole process by a long way. Nobody has this
> table design by accident, they've all been told how or read the docs.
>
> I'm not against the change so much as bemused by it.

The idea is that it is "one less thing to do".

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

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


From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "jd(at)commandprompt(dot)com" <jd(at)commandprompt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 21:40:20
Message-ID: A76FB8ED-7923-4E89-A308-313CAD3805CF@hi-media.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Le 7 janv. 09 à 22:21, Simon Riggs <simon(at)2ndQuadrant(dot)com> a écrit :

>
> On Wed, 2009-01-07 at 12:54 -0500, Tom Lane wrote:
>
>> So, barring objections, I'll go make this happen.
>
> I don't really understand this. Who can set up an inherited table
> structure but can't remember to turn on constraint_exclusion? That is
> the easiest part of the whole process by a long way. Nobody has this
> table design by accident, they've all been told how or read the docs.
>
> I'm not against the change so much as bemused by it.

I think the improvement is not in the usability part but the
performance benefit of avoiding lots of cpu cycles when there's no
gain to hope.

And I like the new option!
--
dim


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 22:14:28
Message-ID: 20090107221428.GR26233@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon,

* Simon Riggs (simon(at)2ndQuadrant(dot)com) wrote:
> I don't really understand this. Who can set up an inherited table
> structure but can't remember to turn on constraint_exclusion? That is
> the easiest part of the whole process by a long way. Nobody has this
> table design by accident, they've all been told how or read the docs.

I can, very easily. It happens whenever we stand up a new server, dump
our tables into it, create our UNION ALL views, and then try to query
them. Sure, we've gotten used to "oh, we need to go check and make sure
constraint_exclusion is on", but it can be annoying, and if we're ever
handing off our table structures/setups to other people we have to
remember to tell them "oh, and don't forget to enable
constraint_exclusion!", etc, etc..

Thanks,

Stephen


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 22:24:10
Message-ID: 200901072224.n07MOAT29470@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Stephen Frost wrote:
-- Start of PGP signed section.
> Simon,
>
> * Simon Riggs (simon(at)2ndQuadrant(dot)com) wrote:
> > I don't really understand this. Who can set up an inherited table
> > structure but can't remember to turn on constraint_exclusion? That is
> > the easiest part of the whole process by a long way. Nobody has this
> > table design by accident, they've all been told how or read the docs.
>
> I can, very easily. It happens whenever we stand up a new server, dump
> our tables into it, create our UNION ALL views, and then try to query
> them. Sure, we've gotten used to "oh, we need to go check and make sure
> constraint_exclusion is on", but it can be annoying, and if we're ever
> handing off our table structures/setups to other people we have to
> remember to tell them "oh, and don't forget to enable
> constraint_exclusion!", etc, etc..

This new change also adds the constraint exclusion overhead only for
inhertance (by default) so it should slightly improve query peformance.

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

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


From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 22:28:55
Message-ID: Pine.GSO.4.64.0901071723400.20568@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 7 Jan 2009, Simon Riggs wrote:

> Who can set up an inherited table structure but can't remember to turn
> on constraint_exclusion?

I thought the whole point of the WIP "Auto Partitioning Patch" was exactly
to enable larger numbers of such people in the future.

--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Simon Riggs <simon(at)2ndQuadrant(dot)com>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 22:46:01
Message-ID: 6731.1231368361@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
>> * Simon Riggs (simon(at)2ndQuadrant(dot)com) wrote:
>>> I don't really understand this. Who can set up an inherited table
>>> structure but can't remember to turn on constraint_exclusion?

> This new change also adds the constraint exclusion overhead only for
> inhertance (by default) so it should slightly improve query peformance.

Right, I think that's the real winning argument for having this: it
gets the benefit of c_e for partitioned tables without imposing overhead
for non-partitioned tables. See Josh B's remarks upthread about
actually going to the trouble of turning c_e off and on on-the-fly to
try to approximate that result.

regards, tom lane


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, jd(at)commandprompt(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <gsmith(at)gregsmith(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-07 23:24:44
Message-ID: 1231370684.18005.95.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Wed, 2009-01-07 at 17:46 -0500, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> >> * Simon Riggs (simon(at)2ndQuadrant(dot)com) wrote:
> >>> I don't really understand this. Who can set up an inherited table
> >>> structure but can't remember to turn on constraint_exclusion?
>
> > This new change also adds the constraint exclusion overhead only for
> > inhertance (by default) so it should slightly improve query peformance.
>
> Right, I think that's the real winning argument for having this: it
> gets the benefit of c_e for partitioned tables without imposing overhead
> for non-partitioned tables. See Josh B's remarks upthread about
> actually going to the trouble of turning c_e off and on on-the-fly to
> try to approximate that result.

OK, now that's a winning argument. Go for it.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Stephen Frost" <sfrost(at)snowman(dot)net>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, jd(at)commandprompt(dot)com, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-08 04:47:30
Message-ID: 3073cc9b0901072047qdab9b61md266057bb14898a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 7, 2009 at 5:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
>>> * Simon Riggs (simon(at)2ndQuadrant(dot)com) wrote:
>>>> I don't really understand this. Who can set up an inherited table
>>>> structure but can't remember to turn on constraint_exclusion?
>
>> This new change also adds the constraint exclusion overhead only for
>> inhertance (by default) so it should slightly improve query peformance.
>
> Right, I think that's the real winning argument for having this: it
> gets the benefit of c_e for partitioned tables without imposing overhead
> for non-partitioned tables. See Josh B's remarks upthread about
> actually going to the trouble of turning c_e off and on on-the-fly to
> try to approximate that result.
>

what i still doesn't understand is why we need a third value at all?
why we simply can't make the new 'partition' behaviour be the default
for c_e on?

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Stephen Frost" <sfrost(at)snowman(dot)net>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, jd(at)commandprompt(dot)com, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Greg Smith" <gsmith(at)gregsmith(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Josh Berkus" <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Do we still need constraint_exclusion?
Date: 2009-01-08 04:54:07
Message-ID: 6636.1231390447@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec> writes:
> what i still doesn't understand is why we need a third value at all?

There are cases for wanting all three.

regards, tom lane