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

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: PSQL 8.4 - partittions - join tables - not optimal plan
Дата
Msg-id 20090911053308.GA2300@a-kretschmer.de
обсуждение исходный текст
Ответ на PSQL 8.4 - partittions - join tables - not optimal plan  (Vratislav Benes <benes@optisolutions.cz>)
Список pgsql-performance
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)

В списке pgsql-performance по дате отправления:

Предыдущее
От: Eugene Morozov
Дата:
Сообщение: Re: Forcing postgresql to use an index
Следующее
От: Jason Tesser
Дата:
Сообщение: View vs Stored Proc Performance