Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-29 Thread Merlin Moncure
On Tue, Aug 28, 2012 at 3:25 PM, Dmitriy Igrishin dmit...@gmail.com wrote: 2012/8/20 Merlin Moncure mmonc...@gmail.com On Sun, Aug 19, 2012 at 8:14 AM, Dmitriy Igrishin dmit...@gmail.com wrote: For various reasons, this often goes the wrong way. Views are often the right way to go. +1 on

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-29 Thread Chris Travers
On Wed, Aug 29, 2012 at 6:15 AM, Merlin Moncure mmonc...@gmail.com wrote: Hm, couple points (and yes, this is a common problem): *) how come you don't have your function depend on the table instead of the view? this has the neat property of having the function automatically track added

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-29 Thread Dmitriy Igrishin
2012/8/29 Merlin Moncure mmonc...@gmail.com On Tue, Aug 28, 2012 at 3:25 PM, Dmitriy Igrishin dmit...@gmail.com wrote: 2012/8/20 Merlin Moncure mmonc...@gmail.com On Sun, Aug 19, 2012 at 8:14 AM, Dmitriy Igrishin dmit...@gmail.com wrote: For various reasons, this often goes the wrong

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-29 Thread Merlin Moncure
On Wed, Aug 29, 2012 at 8:52 AM, Chris Travers chris.trav...@gmail.com wrote: ALTER TABLE fruit ADD apple_id int; ALTER TABLE fruit ADD FOREIGN KEY (apple_id, type) REFERENCES apple (fruit_id, type) DEFERRABLE INITIALLY DEFERRED; And then do the same for orange etc.

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-28 Thread Dmitriy Igrishin
2012/8/20 Merlin Moncure mmonc...@gmail.com On Sun, Aug 19, 2012 at 8:14 AM, Dmitriy Igrishin dmit...@gmail.com wrote: For various reasons, this often goes the wrong way. Views are often the right way to go. +1 on your comment above -- the right way to do views (and SQL in general) is

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-20 Thread Merlin Moncure
On Sun, Aug 19, 2012 at 8:14 AM, Dmitriy Igrishin dmit...@gmail.com wrote: For various reasons, this often goes the wrong way. Views are often the right way to go. +1 on your comment above -- the right way to do views (and SQL in general) is to organize scripts and to try and avoid managing

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-19 Thread Dmitriy Igrishin
2012/8/18 Merlin Moncure mmonc...@gmail.com On Fri, Aug 17, 2012 at 5:44 PM, Tom Lane t...@sss.pgh.pa.us wrote: Adam Mackler adammack...@gmail.com writes: 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

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-18 Thread Craig Ringer
On 08/18/2012 06:49 AM, Merlin Moncure wrote: For various reasons, this often goes the wrong way. Views are often the right way to go. Indeed. I've had queries speed up *hundreds* of times when I convert a function the planner didn't seem to want to inline into a view it can push conditions

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

2012-08-17 Thread Adam Mackler
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

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread Tom Lane
Adam Mackler adammack...@gmail.com writes: 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

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread Merlin Moncure
On Fri, Aug 17, 2012 at 5:44 PM, Tom Lane t...@sss.pgh.pa.us wrote: Adam Mackler adammack...@gmail.com writes: 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

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread Uwe Schroeder
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

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread David Johnston
Included below: 1) Question regarding the ability to inline set-returning functions 2) A comment that not keeping the content between the CREATE VIEW ... AS and the trailing ;|EOF is losing good information to have inside the database. Correct. The reparse time per se is generally not a big

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread Tom Lane
David Johnston pol...@yahoo.com writes: Trying to answer the previous question this one presented itself: I just tried a couple of very simple queries and couldn't get them give me a plan that wasn't a Function Scan. Is it possible that only scalar functions can be inlined? CREATE OR

Re: [GENERAL] Views versus user-defined functions: formatting, comments, performance, etc.

2012-08-17 Thread Chris Travers
On Fri, Aug 17, 2012 at 2:35 PM, Adam Mackler adammack...@gmail.com wrote: 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