From: Hannu Krosing <hannu@tm.ee>
To: Boris Klug <boris.klug@control.de>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Unions and where optimisation
Date: 08 Jan 2003 16:02:15 +0000
Message-ID: <1042041735.3237.1.camel@huli> (raw)
In-Reply-To: <200301081425.48597.boris.klug@control.de>
References: <200301081425.48597.boris.klug@control.de>
On Wed, 2003-01-08 at 13:25, Boris Klug wrote:
> Hello!
>
> I am quite new in the PostgreSQL performance business, done a few years Oracle
> stuff before. My ist question is the following:
>
> We have three table, lets name them rk150, 151 and rk152. They all have a
> timestamp and a order number in common but than different data after this.
> Now I need the data from all tables in one view for a given order number, so
> I created a view
>
> create view orderevents as
> select ts, aufnr from rk150
> union
> select ts, aufnr from rk151
> union
> select ts, aufnr from rk152;
try making the orderevents view like this:
create view orderevents as
select rk.aufnr, sub.ts
from rk150 rk,
( select ts from rk150 where aufnr = rk.aufr
union
select ts from rk151 where aufnr = rk.aufr
union
select ts from rk152 where aufnr = rk.aufr
) as sub
;
this could/should force your desired behavior.
> My question now: Is the optimizer able to move the where clause into unions?
> If so, how I can get him to do it?
>
> Thank you for the help in advance!
--
Hannu Krosing <hannu@tm.ee>
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: hannu@tm.ee, boris.klug@control.de
Subject: Re: Unions and where optimisation
In-Reply-To: <1042041735.3237.1.camel@huli>
References: <200301081425.48597.boris.klug@control.de> <1042041735.3237.1.camel@huli>
* 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