Re: performance on insert/update

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jerome Raupach <jraupach(at)intelcom(dot)fr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: performance on insert/update
Date: 2000-08-29 14:55:34
Message-ID: 1764.967560934@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jerome Raupach <jraupach(at)intelcom(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stuart Foster 2000-08-29 15:32:49 Viewing a function
Previous Message Tom Lane 2000-08-29 14:04:11 Re: How do you detect row version changes in PostgreSQL?