"Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes:

> And that is its plan (attached one is the same, but with costs):
>
>>---------------------------------<cut>--------------------------------<
>  Merge Left Join
>    Merge Cond: ("outer".name = "inner".name)
>    ->  Sort
>          Sort Key: log.name
>          ->  Seq Scan on log_example_3 log
>    ->  Sort
>          Sort Key: uh.name
>          ->  Subquery Scan uh
>                ->  Sort
>                      Sort Key: name
>                      ->  Seq Scan on user_history
>>---------------------------------<cut>--------------------------------<

What version are you running with?

Incidentally with CVS HEAD I see it working:

postgres=# explain select * from (select * from a order by i) as a right join b 
on a.i = b.i ;
                           QUERY PLAN                            
-----------------------------------------------------------------
 Merge Right Join  (cost=299.56..675.13 rows=22898 width=16)
   Merge Cond: (public.a.i = b.i)
   ->  Sort  (cost=149.78..155.13 rows=2140 width=8)
         Sort Key: public.a.i
         ->  Seq Scan on a  (cost=0.00..31.40 rows=2140 width=8)
   ->  Sort  (cost=149.78..155.13 rows=2140 width=8)
         Sort Key: b.i
         ->  Seq Scan on b  (cost=0.00..31.40 rows=2140 width=8)
(8 rows)



> With best regards to all of you,
> Aleksandr.
> ÿþ Merge Left Join  
> (cost=207646.00..213864.12 rows=347851 
> width=62) (actual 
> time=30922.366..32166.518 rows=13908 
> loops=1)

>    Merge Cond: ("outer".name = 
> "inner".name)

>    ->  Sort  (cost=6.71..7.03 rows=127 
> width=30) (actual time=1.117..1.207 
> rows=100 loops=1)

>          Sort Key: log.name

>          ->  Seq Scan on log_example_3 
> log  (cost=0.00..2.27 rows=127 
> width=30) (actual time=0.053..0.177 
> rows=100 loops=1)

>    ->  Sort  
> (cost=207639.29..209008.78 rows=547796 
> width=32) (actual 
> time=30921.171..31467.117 rows=442848 
> loops=1)

>          Sort Key: uh.name

>          ->  Subquery Scan uh  
> (cost=111447.90..118295.35 rows=547796 
> width=32) (actual 
> time=19277.963..21595.874 rows=547796 
> loops=1)

>                ->  Sort  
> (cost=111447.90..112817.39 rows=547796 
> width=32) (actual 
> time=19277.908..20104.568 rows=547796 
> loops=1)

>                      Sort Key: name

>                      ->  Seq Scan on 
> user_history  (cost=0.00..22103.96 
> rows=547796 width=32) (actual 
> time=0.051..1474.143 rows=547796 
> loops=1)

gesundheit.


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to