Re: Union within View vs.Union of Views

From: "Jeff Larsen" <jlar310(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Union within View vs.Union of Views
Date: 2007-11-04 10:11:02
Message-ID: d1f9b6f00711040211g752cbf2he3488cf62c622193@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 11/3/07, Tom Lane wrote:
> "Jeff Larsen" <jlar310(at)gmail(dot)com> writes:
> > My case probably fits the 'special case' description. Not all the
> > columns in each subquery matched up, so there were NULL::text
> > placeholders in some spots in the SELECT. In the case where
> > performance got bad, one of those columns was included in the
> > application's WHERE clause.
>
> Please see if explicitly casting the nulls to the same datatype as the
> other items they're unioned with makes it go fast. It sounds like you
> are hitting the "no type coercions" restriction.

Sure enough, explicitly casting to exactly the same type for each
column did the trick. In fact the union within the view now has a
slight edge over the union of views.

Thanks,

Jeff

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message smiley2211 2007-11-04 16:28:30 Postgresql.conf Settings
Previous Message Jeff Larsen 2007-11-04 01:57:21 Re: Union within View vs.Union of Views