X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 72EA69FA4A7 for ; Fri, 30 Jun 2006 11:13:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75251-08 for ; Fri, 30 Jun 2006 11:13:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id BB1299FA163 for ; Fri, 30 Jun 2006 11:13:02 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (T916d.t.pppool.de [89.55.145.109]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 24BFE65874 for ; Fri, 30 Jun 2006 16:14:38 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id B0A68181C1C71 for ; Fri, 30 Jun 2006 16:13:11 +0200 (CEST) Message-ID: <44A53177.30004@logix-tt.com> Date: Fri, 30 Jun 2006 16:13:11 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Thunderbird 1.5.0.2 (X11/20060516) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Views and query planner References: <1151670948.27032.5.camel@localhost.localdomain> <2D1768EE-58E1-4260-A940-3ED78D560EAB@seespotcode.net> <1151673822.27032.9.camel@localhost.localdomain> In-Reply-To: <1151673822.27032.9.camel@localhost.localdomain> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/334 X-Sequence-Number: 25570 Hi, Mario, Mario Splivalo wrote: >>> Is postgres going to make one query plan, or each view has it own >>> query >>> plan? >> Have you taken a look at the EXPLAIN ANALYZE output of the queries? >> You can see exactly which plan PostgreSQL will use. > > So, the performance will be the same if I use view on view, or I create > big select with those view definitions. Yes, usually[1]. Internally, PostgreSQL generates a big query out of the stack of views, and then lets the optimizer do its work. The query performance will be the same, but the planning performance may vary. (This effect can be mildered by careful use of prepared statements.) HTH, Markus [1] Queries reaching some complexity level may lead to different plans, due to optimizer limits, the gequo kicking in, or other effects. -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org