pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jerome Raupach <jraupach@intelcom.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: performance on insert/update
Date: Tue, 29 Aug 2000 10:55:34 -0400
Message-ID: <1764.967560934@sss.pgh.pa.us> (raw)
In-Reply-To: <39ABA7F2.6180FFC7@intelcom.fr>
References: <39ABA7F2.6180FFC7@intelcom.fr>

Jerome Raupach <jraupach@intelcom.fr> writes:
> I have a big problem of performance, please help me.

You could code the update so it only evaluates the view once,
rather than twice per table2 row as you now have it:

UPDATE table2 SET
	nb=table2.nb+view1.nb,
	time=table2.time+view1.time
FROM view1
WHERE view1.f1=table2.f1 and view1.date=table2.date;

Subselects are nice, but they're not cheap.  Joins are faster.

The view itself also seems to be pretty inefficiently coded,
although I'm not sure you can do much better given that GROUP BY
doesn't really work in views right now.  Hopefully by 7.2 there
will be a better way to do the view.

			regards, tom lane



view thread (2+ messages)

Message-ID: <1764.967560934@sss.pgh.pa.us>
Permalink:  ../1764.967560934@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1764.967560934@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 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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jraupach@intelcom.fr
  Subject: Re: performance on insert/update
  In-Reply-To: <1764.967560934@sss.pgh.pa.us>
  References: <39ABA7F2.6180FFC7@intelcom.fr> <1764.967560934@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