Views versus user-defined functions: formatting, comments, performance, etc.

Поиск
Список
Период
Сортировка
От Adam Mackler
Тема Views versus user-defined functions: formatting, comments, performance, etc.
Дата
Msg-id CAFC21LoH-BLANZV46o5HZo87VO13DpEsBPDS3wiDtywwb0xQWg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Views versus user-defined functions: formatting, comments, performance, etc.  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Views versus user-defined functions: formatting, comments, performance, etc.  (Uwe Schroeder <uwe@oss4u.com>)
Re: Views versus user-defined functions: formatting, comments, performance, etc.  (Chris Travers <chris.travers@gmail.com>)
Список pgsql-general
Hi:

I notice when I save a view, I lose all the formatting and comments.
As I was writing a complicated view, wanting to retain the format and
comments, I thought I could just save it as a function that returns a
table value.  A function would evaluate to the same value as a view,
but changing it later might be less confusing.

However, I'm guessing (since I don't know anything about the
internals) that the loss of formatting and comments is a result of the
view being processed and stored in a more computer-friendly format,
while functions are simply stored as the text that I type.  That gives
me reason to suspect there may be performance or other differences
between the same SQL statement stored either as a view or a
user-defined function.

So that's my question: as someone who doesn't have a problem with
putting a pair of empty parentheses at the end of a table variable
name, what factors should I be thinking of while deciding whether to
store my self-composed, multi-hundred-line long SQL statement as a
view or a function?

--
Adam Mackler


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

Предыдущее
От: Sébastien Lorion
Дата:
Сообщение: Re: Messy data models (Re: Visualize database schema)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Views versus user-defined functions: formatting, comments, performance, etc.