Re: JOIN performance

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: JOIN performance
Дата
Msg-id 23901.1095728070@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: JOIN performance  ("Dean Gibson (DB Administrator)" <postgresql3@ultimeth.com>)
Ответы Re: JOIN performance
Re: JOIN performance
Список pgsql-sql
"Dean Gibson (DB Administrator)" <postgresql3@ultimeth.com> writes:
> Question:  why do the last two column definitions in the second VIEW change 
> the scan on _LicHD from indexed to sequential ??

It's the CASE that's getting you.  The poor plan is basically because
the sub-view isn't getting "flattened" into the upper query, and so it's
not possible to choose a plan for it that's dependent on the upper query
context.  And the reason it's not getting flattened is that subselects
that are on the nullable side of an outer join can't be flattened unless
they have nullable targetlists --- otherwise the results might not go to
NULL when they are supposed to.  A CASE construct is always going to be
treated as non-nullable.

Fixing this properly is a research project, and I haven't thought of any
quick-and-dirty hacks that aren't too ugly to consider :-(

In the meantime, you could easily replace that CASE construct with a
min() function that's declared strict.  I think date_smaller would
do nicely, assuming the columns are actually of type date.
        regards, tom lane


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

Предыдущее
От: "Dean Gibson (DB Administrator)"
Дата:
Сообщение: Re: JOIN performance
Следующее
От: "Dean Gibson (DB Administrator)"
Дата:
Сообщение: Re: JOIN performance