X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 01CB9DAEAC for ; Thu, 27 Oct 2005 11:38:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63725-05 for ; Thu, 27 Oct 2005 14:38:02 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CDADADAD5F for ; Thu, 27 Oct 2005 11:38:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9REc23c018900; Thu, 27 Oct 2005 10:38:02 -0400 (EDT) To: Svenne Krap Cc: pgsql-performance@postgresql.org Subject: Re: Perfomance of views In-reply-to: <4360B375.8000303@krap.dk> References: <435FA002.4060509@krap.dk> <43609EF4.8060907@archonet.com> <4360B375.8000303@krap.dk> Comments: In-reply-to Svenne Krap message dated "Thu, 27 Oct 2005 13:01:09 +0200" Date: Thu, 27 Oct 2005 10:38:02 -0400 Message-ID: <18899.1130423882@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/420 X-Sequence-Number: 15188 Svenne Krap writes: > The ways I have considered was : > 1) write a big query in hand (not preferred as it gets hard to manage) > 2) write layers of views (still not prefered as I still have to remember > to put on the right conditions everywhere) > 3) write layers of sql-functions (returning the right sets of rows from > the underlying tables) - which I prefer from a development angel .. it > gets very clean and I cant forget a parameter anywhere. #1 and #2 should behave pretty similarly, assuming that the "one big query" would have been structured the same way as the nest of views is. #3 unfortunately will pretty much suck, because there's no chance for cross-level optimization. There's been some discussion of inline-expanding SQL functions that return sets when they are called in FROM, which would make a SQL function that contains just a SELECT effectively equivalent to a view as far as the planner's powers of optimization go. No one's tried to make it happen yet though. regards, tom lane