Re: strange view performance

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: strange view performance
Дата
Msg-id 26554.1304289034@sss.pgh.pa.us
обсуждение исходный текст
Ответ на strange view performance  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I am solving  a strange situation, where using a view is slower than
> using same tables directly.

> The view is defined as

> CREATE VIEW v1 AS
>   SELECT *
>     FROM A
>                LEFT JOIN B
>                LEFT JOIN C
>                LEFT JOIN D

> and query is
>    SELECT *
>       FROM T
>                  LEFT JOIN v

> this query is slower than:

> SELECT *
>    FROM T
>               LEFT JOIN A
>               LEFT JOIN B
>               LEFT JOIN C
>               LEFT JOIN D

> Is there a some reason for this behave?

Well, they don't necessarily mean the same thing --- these are only
logically equivalent if the left joins all commute, which would depend
on the ON conditions.

> [ EXPLAIN outputs ]

But I also notice that you are using collapse/geqo limits of 12 for
queries that involve 13 base relations, so that'd mean that syntactic
differences could lead to plan differences too.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Select For Update and Left Outer Join
Следующее
От: Patrick Earl
Дата:
Сообщение: Re: Select For Update and Left Outer Join