pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Damien Dougan <damien.dougan@mobilecohesion.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Very Poor Insert Performance
Date: Wed, 29 Oct 2003 09:23:19 -0500
Message-ID: <3667.1067437399@sss.pgh.pa.us> (raw)
In-Reply-To: <200310291022.24035.damien.dougan@mobilecohesion.com>
References: <200310271626.52839.damien.dougan@mobilecohesion.com>
	<2493.1067285528@sss.pgh.pa.us>
	<200310291022.24035.damien.dougan@mobilecohesion.com>

Damien Dougan <damien.dougan@mobilecohesion.com> writes:
> Now, our problem seems to be the delays introduced by reading from the
> public views.

Your initial message stated plainly that the problem was in INSERTs;
it's not surprising that you got unhelpful advice.

> View definition:
> [ huge view full of LEFT JOINs ]

> As you can see, the PublicView is resulting in a huge nested loop,
> with an index scan of the contact only occurring at the end. I would
> have expected something more like:

> (1) An index scan of the contact table to determine the correct contact
> (2) An index scan of the address table using the rel_contact_has_address.address_id to obtain the (relatively small - max 16, and typically 2) addresses
> (3) A number of joins - at the same level rather than looping - to obtain the detailnames for the new column names of the public view

Your LEFT JOINs are constraining the join order --- see 
http://www.postgresql.org/docs/7.3/static/explicit-joins.html
You'll need to reorder the joins into something that does what you want.

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <3667.1067437399@sss.pgh.pa.us>
Permalink:  ../3667.1067437399@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3667.1067437399@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, damien.dougan@mobilecohesion.com
  Subject: Re: Very Poor Insert Performance
  In-Reply-To: <3667.1067437399@sss.pgh.pa.us>

* 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