Re: subselect requires offset 0 for good performance.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: subselect requires offset 0 for good performance.
Дата
Msg-id 8360.1375476683@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: subselect requires offset 0 for good performance.  (Scott Marlowe <scott.marlowe@gmail.com>)
Ответы Re: subselect requires offset 0 for good performance.  (Scott Marlowe <scott.marlowe@gmail.com>)
Список pgsql-performance
Scott Marlowe <scott.marlowe@gmail.com> writes:
> Yep. Added the indexes and performance went right into the dumper. New
> plan on new table with old data added in random order now looks like
> the old table, only worse because it's on a slower drive. Just to be
> complete here's the plan: http://explain.depesz.com/s/PYH Note that I
> created new table with order by random() and created indexes. Ran
> analyze on it, and the select plan looks similar now:
> http://explain.depesz.com/s/bsE

> So maybe I can make a test case now. But to summarize, when it can use
> indexes this query gets REAL slow because it lacks a materialize step.
> That seem about right?

Well, the plans shown here could *not* use a materialize step because the
inner scan makes use of a value from the current outer row.  The
materialized plan has to omit one of the index conditions from the inner
scan and then apply it as a join condition.

I suspect the real reason that the fast case is fast is that the inner
relation, even without the p.tree_sortkey >= pro_partners.tree_sortkey
condition, is empty, and thus the join runs very quickly.  But the planner
doesn't know that.  Its estimate of the row count isn't very large, but
it's definitely not zero, plus it thinks that adding the additional index
condition reduces the rowcount by a factor of 3 from there.  So it comes
to the wrong conclusion about the value of materializing a fixed inner
relation as opposed to using a parameterized indexscan.

Have you tried increasing the statistics targets for these join columns?
It's also possible that what you need to do is adjust the planner's
cost parameters ...

            regards, tom lane


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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: subselect requires offset 0 for good performance.
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: to many locks held