pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Larsen <jlar310@gmail.com>
To: Dean Rasheed <dean_rasheed@hotmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance problem with UNION ALL view and domains
Date: Fri, 23 Nov 2007 10:29:07 -0600
Message-ID: <d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com> (raw)
In-Reply-To: <BAY113-W15FECB293A73B10686F8CEF27A0@phx.gbl>
References: <BAY113-W15FECB293A73B10686F8CEF27A0@phx.gbl>

On Nov 23, 2007 7:29 AM, Dean Rasheed <dean_rasheed@hotmail.com> wrote:
> I am having a performance problem trying to query a view which is a
> UNION ALL of 2 tables. I have narrowed the problem down to my use of
> DOMAINS in the underlying table. So in the test-case below, when the
> column "a" is of domain type foo_text, the query runs slowly using
> the following plan:

I don't know much about DOMAINS, but I did learn somethings about
views, unions and where conditions when I posted a similar performance
question. The best answer was, of course, from Tom Lane here:

http://archives.postgresql.org/pgsql-performance/2007-11/msg00041.php

In my case, the data types in each segment of the union were not
originally identical, preventing the planner from efficiently pushing
the qualifications down to the individual segments prior to the union.

In your case the use of a DOMAIN type may be one of those 'special
cases' forcing the planner to perform the union first, then apply the
conditions.

Jeff



view thread (4+ messages)  latest in thread

Message-ID: <d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com>
Permalink:  ../d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com/
Also on:    postgresql.org/message-id/d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: jlar310@gmail.com, dean_rasheed@hotmail.com
  Subject: Re: Performance problem with UNION ALL view and domains
  In-Reply-To: <d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com>
  References: <BAY113-W15FECB293A73B10686F8CEF27A0@phx.gbl> <d1f9b6f00711230829q6bbc89b0gf1ed9465dd7daab@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox