Re: Question about LEFT JOIN and query plan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Question about LEFT JOIN and query plan
Дата
Msg-id 25498.1283534083@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Question about LEFT JOIN and query plan  (Kaloyan Iliev Iliev <kaloyan@digsys.bg>)
Ответы Re: Question about LEFT JOIN and query plan  (Kaloyan Iliev Iliev <kaloyan@digsys.bg>)
Список pgsql-performance
Kaloyan Iliev Iliev <kaloyan@digsys.bg> writes:
> I have I query which behave strangely (according to me).
> According to the first plan PG makes absolutely unnecessary seq scan on
> tables "invoices" and "domeini" and etc.

I think you might get better results if you could get this rowcount
estimate a bit more in line with reality:

>              ->  Seq Scan on debts_desc dd  (cost=0.00..2866.52 rows=23782 width=46) (actual time=0.481..45.085
rows=1037loops=1) 
>                    Filter: (active AND (NOT paid) AND has_proform AND (NOT storned))

It's choosing to hash instead of doing (what it thinks will be) 23K
index probes into the other table.  For 1000 probes the decision
might be different.

I don't know if raising the stats target for that table will be enough
to fix it.  Most likely those four conditions are not uncorrelated.
You might need to think about revising the table's representation
so that the query condition can be simpler and thus more accurately
estimated.

            regards, tom lane

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

Предыдущее
От: Gerhard Wiesinger
Дата:
Сообщение: Re: Major performance problem after upgrade from 8.3 to 8.4
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Major performance problem after upgrade from 8.3 to 8.4