Re: a JOIN on same table, but 'slided over' - Mailing list pgsql-general

From Alban Hertroys
Subject Re: a JOIN on same table, but 'slided over'
Date
Msg-id 4683821D.8010802@magproductions.nl
Whole thread Raw
In response to Re: a JOIN on same table, but 'slided over'  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Responses Re: a JOIN on same table, but 'slided over'  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
List pgsql-general
Rafal Pietrak wrote:
> Gurjeet,
>
> Focusing on the standars solution, I did some 'exercises' - works fine,
> just learning.
>
> But the ambarasing thing is, that I looks like I really don't get it,
> meaning - what exactly the internal query does. I've never ever seen or
> used a subquery with data/params from 'upper level' query used within a
> subquery - any time I've written a hierarchical query (e.g. with
> subqueries), the relations were always hierarchical. In other words, I
> was always able to run an internal subquery outside of the compound
> query and get consistant results. With this one I cannot do that due to
> the 'entanglement' of t3 and t1.

This is called a 'correlated subquery'. Basically the subquery is
performed for each record in the top query.

Google gave me this:
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/sqlp/rbafycorrs.htm

And there's probably more to find. Interestingly enough wikipedia
doesn't seem to have an article on the subject.

> Postgress query plan from EXPLAIN doesn't help me here - probably I'm
> unable to interpret it correctly without 'a paradigm mind shift'.
>
> So, would you mind commenting a little on how exactly the t1.id
> influences subquery (with t3), and the result influences back the
> selection of t1 set?
>
> Will greatly apreciate that.


--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: Bruce McAlister
Date:
Subject: Re: AutoVacuum Behaviour Question
Next
From: Alban Hertroys
Date:
Subject: Re: AutoVacuum Behaviour Question