Re: Do Views offer any performance advantage?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Do Views offer any performance advantage?
Дата
Msg-id 8832.1050427583@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Do Views offer any performance advantage?  ("Robert John Shepherd" <robert@reviewer.co.uk>)
Ответы Re: Do Views offer any performance advantage?  (Andreas Pflug <Andreas.Pflug@web.de>)
Список pgsql-performance
"Robert John Shepherd" <robert@reviewer.co.uk> writes:
> Whilst I often use views for convenience, is there any performance
> advantage at all in using a view rather than running the same query
> directly on the tables themselves?

No, a view is just a macro.

There is probably some minuscule cost difference involved --- you save
parsing and parse analysis of a long query string.  On the other hand,
you pay to pull the view definition from the catalogs and merge it into
the given query.  I'd not care to hazard a guess on whether the actual
net cost is more or less; but in any case these costs will be swamped
by query planning and execution, if the query is complex.

If you're concerned about reducing parse/plan overhead for repetitive
queries, the prepared-statement facility (new in 7.3) is what to look
at.  Views won't do much for you.

            regards, tom lane


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

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: for help!
Следующее
От: Greg Stark
Дата:
Сообщение: Using indexes for like foo% type queries when foo isn't constant (not a locale issue)