Re: Query performance issue

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query performance issue
Дата
Msg-id 12017.1315149499@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Query performance issue  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Ответы Re: Query performance issue  (Jayadevan <Jayadevan.Maymala@ibsplc.com>)
Список pgsql-performance
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Thanks for posting the query and related schema.  I tried working
> through it, but I keep coming back to this sort, and wondering how a
> sort can have 1121 rows as input and 2673340321 rows as output.  Does
> anyone have any ideas on what could cause that?

Mergejoin rescan.  There really are only 1121 rows in the data, but
the parent merge join is pulling them over and over again --- evidently
there are a lot of equal keys in the data.  The EXPLAIN ANALYZE
machinery counts each fetch as a new row, even after a mark/restore.

The planner does know about that effect and will penalize merge joins
when it realizes there are a lot of duplicate keys in the input.  In
this case I'm thinking that the drastic underestimate of the size of the
other side of the join results in not penalizing the merge enough.

(On the other hand, hash joins don't like equal keys that much either...)

            regards, tom lane

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

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: Query performance issue
Следующее
От: Jayadevan
Дата:
Сообщение: Re: Query performance issue