Stephan Szabo wrote:
>
> 
> I think you'd want to move the entire query excepting the lastml where
> condition into a single subselect in the outer from with the lastml
> condition on the outside:
>  select * from (<old query minus lastml condition>) as blah where
>   lastml=2;
> 
> However, I don't think this changes the computation that it's doing
> (simple example explains still show two subquery runs).
> 

Yep, that works.  I wasn't familiar with how the subselect in the from part works.  
But as 
you say an explain still shows it doing the index scan twice.

 From the postgres docs:

      A sub-SELECT can appear in the FROM clause. This acts as though its output were 
created as a temporary table for the duration of this single SELECT command. Note that 
the 
sub-SELECT must be surrounded by parentheses, and an alias must  be provided for it.

So does postgres actually use a temporary table behind the scenses?  It appears not.


-- 
Joseph Shraibman
[EMAIL PROTECTED]
Increase signal to noise ratio.  http://www.targabot.com


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

Reply via email to