From: Markus Schaber <schabi@logix-tt.com>
To: pgsql-sql@postgresql.org
Subject: Re: Views and query planner
Date: Fri, 30 Jun 2006 16:13:11 +0200
Message-ID: <44A53177.30004@logix-tt.com> (raw)
In-Reply-To: <1151673822.27032.9.camel@localhost.localdomain>
References: <1151670948.27032.5.camel@localhost.localdomain>
<2D1768EE-58E1-4260-A940-3ED78D560EAB@seespotcode.net>
<1151673822.27032.9.camel@localhost.localdomain>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: schabi@logix-tt.com
Subject: Re: Views and query planner
In-Reply-To: <44A53177.30004@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox