Re: Indexing UNIONs

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Indexing UNIONs
Date: 2002-07-16 11:45:53
Message-ID: 20020716114553.GB29323@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Jul 15, 2002 at 17:31:24 -0700,
Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> Stephan,
>
> > We had a discussion recently on -general about this. Right now the
> > planner won't push the conditions down into the arms of the union because
> > noone's been sure under what conditions the optimization is safe.
>
> So, if performance is horrible with the view, I should use a dummy table to
> hold the Unioned data and index that instead?

It wouldn't have to be a dummy table. You could have both sets of data
in the same table. Since they seem to be related enough that you went to
the trouble to give them compatible primary keys this may not be
inappropiate (though you must have had some reason for keeping them separate).
You can use a flag to indicate what the data type is. If you need fast
access to the smaller part of the table, a partial index might work.
If the column that didn't apply to the one table is always not null in the
other table, you could use is null on that column as your flag.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-07-16 13:44:14 Re: [SQL] line datatype
Previous Message Rajesh Kumar Mallah. 2002-07-16 11:34:24 Re: How do I concatenate row-wise instead of column-wise?