[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] Views and query planner
From:       Markus Schaber <schabi () logix-tt ! com>
Date:       2006-06-30 14:13:11
Message-ID: 44A53177.30004 () logix-tt ! com
[Download RAW message or body]

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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic