X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B394F476347 for ; Tue, 15 Apr 2003 13:26:24 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D5CBB476342 for ; Tue, 15 Apr 2003 13:26:23 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3FHQNU6008833; Tue, 15 Apr 2003 13:26:23 -0400 (EDT) To: "Robert John Shepherd" Cc: pgsql-performance@postgresql.org Subject: Re: Do Views offer any performance advantage? In-reply-to: <001f01c30366$93427720$f3b0313e@LAIKA> References: <001f01c30366$93427720$f3b0313e@LAIKA> Comments: In-reply-to "Robert John Shepherd" message dated "Tue, 15 Apr 2003 16:49:18 +0100" Date: Tue, 15 Apr 2003 13:26:23 -0400 Message-ID: <8832.1050427583@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/136 X-Sequence-Number: 1642 "Robert John Shepherd" writes: > Whilst I often use views for convenience, is there any performance > advantage at all in using a view rather than running the same query > directly on the tables themselves? No, a view is just a macro. There is probably some minuscule cost difference involved --- you save parsing and parse analysis of a long query string. On the other hand, you pay to pull the view definition from the catalogs and merge it into the given query. I'd not care to hazard a guess on whether the actual net cost is more or less; but in any case these costs will be swamped by query planning and execution, if the query is complex. If you're concerned about reducing parse/plan overhead for repetitive queries, the prepared-statement facility (new in 7.3) is what to look at. Views won't do much for you. regards, tom lane