From: | Jason Tesser <jasontesser(at)gmail(dot)com> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: View vs Stored Proc Performance |
Date: | 2009-09-11 18:56:31 |
Message-ID: | 98bbb46a0909111156k4dd7a165ife9cc46578e1c0cc@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
OK so in my case I have a Person, Email, Phone and Address table. I want to
return the Person and an Array of the others. so my return type would be
something like Person, Email[], Phone[], Address[]
When passed a personId.
Are you saying this is better in a view. Create a view that can return that
as oppessed to 1. defining a type for a function to return or 2. a function
that returns 4 out parameters (Person, Address[] ,....)
Thanks
On Fri, Sep 11, 2009 at 1:37 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Fri, Sep 11, 2009 at 11:46 AM, Jason Tesser <jasontesser(at)gmail(dot)com>
> wrote:
> > Is it faster to use a Stored Proc that returns a Type or has Out
> Parameters
> > then a View? Views are easier to maintain I feel. I remember testing
> this
> > around 8.0 days and the view seemed slower with a lot of data.
>
> for the most part, a view can be faster and would rarely be slower.
> Views are like C macros for you query...they are expanded first and
> then planned. Functions (except for very simple ones) are black boxes
> to the planner and can materially hurt query performance in common
> cases. The only case where a function would win is when dealing with
> conner case planner issues (by forcing a nestloop for example).
>
> merlin
>
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua Rubin | 2009-09-11 20:16:49 | Persistent Plan Cache |
Previous Message | Kevin Grittner | 2009-09-11 18:22:21 | Re: odd iostat graph |