Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CFBAF476672 for ; Wed, 15 Jan 2003 14:58:31 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 97AF6477391 for ; Wed, 15 Jan 2003 14:08:27 -0500 (EST) Received: from klaster.net (pc148.krakow.cvx.ppp.tpnet.pl [213.76.38.148]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id C7BCA2B2AE; Wed, 15 Jan 2003 20:05:15 +0100 (CET) Message-ID: <3E25B29C.9040408@klaster.net> Date: Wed, 15 Jan 2003 20:12:28 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: PgSQL Performance ML Subject: Re: complicated queries in pl/pgsql References: <3E23EC83.9060802@klaster.net> <200301131044.50424.josh@agliodbs.com> In-Reply-To: <3E23EC83.9060802@klaster.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/118 X-Sequence-Number: 765 Josh Berkus wrote: > Tomasz, > > > >What happens to view planning - is it performed > >during view creation, or rather each time view is quered? > > > Each time the view is executed. The only savings in running a view over a > regular query is that the view will have taken care of some reference > expansion and JOIN explication during the CREATE process, but not planning. > Also, views can actually be slower if the view is complex enough that any > query-time parameters cannot be "pushed down" into the view. Thanks a lot. I'm asking, because I use some queries which are easy to change into views. Most of their execution time takes planning, they use 5-10 explicit table joins with not too many rows in these tables and returns few values. Now I know, that queries inside pl/pgsql functions are better in these situations: - complex queries whith deep parameters - execution several times during conection lifetime. Can anyone add something? Tomasz Myrta