From: Dean Gibson (DB Administrator) <postgresql@ultimeth.com>
To: pgsql-performance@postgresql.org
Subject: Re: Q on views and performance
Date: Fri, 22 Feb 2008 17:48:48 -0800
Message-ID: <47BF7B80.1040309@ultimeth.com> (raw)
In-Reply-To: <c2350ba40802221249h37913d0cyaa6387a93c55fe69@mail.gmail.com>
References: <c2350ba40802221249h37913d0cyaa6387a93c55fe69@mail.gmail.com>
On 2008-02-22 12:49, Kynn Jones wrote:
> Of course, I expect that using views V<int1> and V<int2>... would
> result in a loss in performance relative to a version that used bona
> fide tables T<int1> and T<int2>. My question is, how can I minimize
> this performance loss?
That used to be my thoughts too, but I have found over the years that
the PostgreSQL execution planner is able to "flatten" SELECTs using
VIEWs, ALMOST ALWAYS in a way that does not adversely affect
performance, and often gives an IMPROVEMENT in performance, probably
because by using VIEWs I am stating the query problem in a better way
than if I try to guess the best way to optimize a SELECT.
I have at least a 10:1 ratio of VIEWs to TABLEs. Occasionally, with
some query that is slow, I will try to rewrite it without VIEWs. This
ALMOST NEVER results in an improvement in performance, and when it does,
I am able to find another way to write the VIEW and SELECT to recapture
the gain.
-- Dean
--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.
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-performance@postgresql.org
Cc: postgresql@ultimeth.com
Subject: Re: Q on views and performance
In-Reply-To: <47BF7B80.1040309@ultimeth.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