Re: performance on insert/update - Mailing list pgsql-sql

From Tom Lane
Subject Re: performance on insert/update
Date
Msg-id 1764.967560934@sss.pgh.pa.us
Whole thread Raw
In response to performance on insert/update  (Jerome Raupach <jraupach@intelcom.fr>)
List pgsql-sql
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 SETnb=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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: How do you detect row version changes in PostgreSQL?
Next
From: Webb Sprague
Date:
Subject: Re: Re: Argument variables for select