pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan Ellis <jonathan@utahpython.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: Premature view materialization in 8.2?
Date: Fri, 6 Apr 2007 12:03:50 -0600
Message-ID: <e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.com> (raw)
In-Reply-To: <15399.1175882434@sss.pgh.pa.us>
References: <e06563880704051146r357cb15by7e498c6d796b093a@mail.gmail.com>
	<28349.1175838196@sss.pgh.pa.us>
	<e06563880704052251j68c86dafx5ba5a8f10fb28268@mail.gmail.com>
	<261.1175840636@sss.pgh.pa.us>
	<e06563880704060724n17a1de97j5d64fafc1ea95b21@mail.gmail.com>
	<15092.1175881227@sss.pgh.pa.us>
	<e06563880704061057q46db0f90w5128ce74471b53ad@mail.gmail.com>
	<15399.1175882434@sss.pgh.pa.us>

On 4/6/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Jonathan Ellis" <jonathan@utahpython.org> writes:
> > I can do that...  you don't think the fact I mentioned, that
> > redefining the view to leave out the expensive function fixes the
> > problem, is relevant?
>
> Hm, I'd not have thought that an expensive function would get evaluated
> partway up the join tree, but maybe that's wrong.  You never did show
> us the actual view definition ...

It was in my original post unless it got clipped:

The problem seems to be that clan_members_v contains a call to an
expensive function:

create or replace view clan_members_v as
select cm.clan_id, cm.user_id, cp.party_id, cm.date_accepted,
  p.name as party_name, p_tp_total(p.id)::int as tp_total
from clan_members cm, clan_participants cp, parties p
where cm.user_id = p.user_id
and p.id = cp.party_id
;

p_tp_total takes around 50ms per row.

If I create clan_members_v without the function call, the original
query's speed goes to the 150ms range on 8.2 as well.



view thread (11+ messages)  latest in thread

Message-ID: <e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.com>
Permalink:  ../e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.com/
Also on:    postgresql.org/message-id/e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: jonathan@utahpython.org, tgl@sss.pgh.pa.us
  Subject: Re: Premature view materialization in 8.2?
  In-Reply-To: <e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.com>
  References: <e06563880704051146r357cb15by7e498c6d796b093a@mail.gmail.com> <28349.1175838196@sss.pgh.pa.us> <e06563880704052251j68c86dafx5ba5a8f10fb28268@mail.gmail.com> <261.1175840636@sss.pgh.pa.us> <e06563880704060724n17a1de97j5d64fafc1ea95b21@mail.gmail.com> <15092.1175881227@sss.pgh.pa.us> <e06563880704061057q46db0f90w5128ce74471b53ad@mail.gmail.com> <15399.1175882434@sss.pgh.pa.us> <e06563880704061103w10e19b96s4223527ebce6b33b@mail.gmail.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