Re: PSQL 8.4 - partittions - join tables - not optimal plan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In response to Vratislav Benes :
> but when I try make a condition by join table, the query plan is not optimal:
> 
> 
> select period_id from periods where y=2009 and w=14;
>  period_id
> -----------
>        704
> (1 row)
> 
> 
> explain select sum(s_pcs),sum(s_val)
> from data d inner join periods p on d.period_id=p.period_id
> where p.y=2009 and p.w=14;                                 

How about

select sum(s_pcs),sum(s_val)
from data d inner join periods p on d.period_id=p.period_id
where p.y=2009 and p.w=14
and p.period_id in (select period_id from periods where y=2009 and w=14);

Untested.


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux