Re: Unions and where optimisation - Mailing list pgsql-performance

From Hannu Krosing
Subject Re: Unions and where optimisation
Date
Msg-id 1042044560.3237.7.camel@huli
Whole thread Raw
In response to Re: Unions and where optimisation  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-performance
On Wed, 2003-01-08 at 14:32, Tomasz Myrta wrote:
> Hannu Krosing wrote:
>
> >
> > 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.
> >
>
> Hannu, does it work?

Nope! Sorry.

SQL spec clearly states that subqueries in FROM clause must not see each
other ;(

It would work in WITH part of the query, which will hopefully be
implemented in some future PG version, perhaps even 7.4 as WITH is the
prerequisite for implementing SQL99 recursive queries, and RedHat has
shown an strongish interest in implementing these.

> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Hannu Krosing <hannu@tm.ee>

pgsql-performance by date:

Previous
From: Boris Klug
Date:
Subject: Re: Unions and where optimisation
Next
From: "enediel"
Date:
Subject: postgresql in cluster of servers