Re: Views- Advantages and Disadvantages

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Views- Advantages and Disadvantages
Дата
Msg-id 17452.1178817789@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Views- Advantages and Disadvantages  ("Leif B. Kristensen" <leif@solumslekt.org>)
Ответы Re: Views- Advantages and Disadvantages  ("Leif B. Kristensen" <leif@solumslekt.org>)
Список pgsql-general
"Leif B. Kristensen" <leif@solumslekt.org> writes:
> [ this query got slow in 8.2: ]
>     $query = "select person_id, pb_date from tmg_persons
>                 where father_id = $p or mother_id = $p
>                 order by pb_date";

> tmg_persons is a view involving several function calls, and is a legacy
> from an earlier, flatter data model where the 'persons' table actually
> had this structure. I'm still using it in my Web application, and the
> primary function of the view is to make an easy export:

> CREATE OR REPLACE VIEW tmg_persons AS
> SELECT
>     person_id,
>     get_parent(person_id,1) AS father_id,
>     get_parent(person_id,2) AS mother_id,
>     last_edit,
>     get_pbdate(person_id) AS pb_date,
>     get_pddate(person_id) AS pd_date,
>     gender AS s,
>     living AS l,
>     is_public AS p
> FROM persons;

Are get_parent() and/or get_pbdate() marked volatile by any chance?
8.2 is more conservative about optimizing sub-selects involving volatile
functions than previous releases were, because we got complaints about
surprising behavior when a volatile function is executed more or fewer
times than the text of the query would suggest.  If they are really
stable or immutable, marking them so would probably help here.  (If they
fetch from another table, stable is the right marking.)

            regards, tom lane

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

Предыдущее
От: David Wall
Дата:
Сообщение: Re: Replication for PG 8 recommendations
Следующее
От: "Leif B. Kristensen"
Дата:
Сообщение: Re: Views- Advantages and Disadvantages