Re: Constraint exclusion in views

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Constraint exclusion in views
Date: 2012-11-04 17:32:56
Message-ID: CAGTBQpYoy+87LrqpxmMnt4f=8RMaLCnz5SpDn7fQt-43+BNMFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sat, Nov 3, 2012 at 10:23 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>>> Funny thing is, if I set constraint_exclusion=on, it works as
>>> expected. But not with constraint_exclusion=partition.
>
>> The difference between "on" and "partition" is how it treats UNION.
>> This seems to be working as designed.
>
> Well, what "partition" actually means is "only bother to try constraint
> exclusion proofs on appendrel members". UNION ALL trees will get
> flattened into appendrels in some cases. In a quick look at the code,
> it seems like in recent releases the restrictions are basically that the
> UNION ALL arms have to (1) each be a plain SELECT from a single table
> with no WHERE restriction; (2) all produce the same column datatypes;
> and (3) not have any volatile functions in the SELECT lists. I might be
> missing something relevant to the OP's case, but it's hard to tell
> without a concrete example.

I would think our view succeeds all those tests, but I'm not entirely
sure about 2. It does use coalesce too, but I really doubt coalesce is
volatile... right?

I don't have access to the code during the weekend, but I'll check
first thing tomorrow whether we have some datatype inconsistencies I
didn't notice.

Thanks for the hint.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dong Ye 2012-11-04 22:23:17 Re: dbt2 performance regresses from 9.1.6 to 9.2.1
Previous Message Gunnar "Nick" Bluth 2012-11-04 08:48:11 Re: Re: Increasing work_mem and shared_buffers on Postgres 9.2 significantly slows down queries