Thanks to visit codestin.com
Credit goes to postgrespro.com

Re: Slow UPADTE, compared to INSERT - Mailing list pgsql-performance

From Richard Huxton
Subject Re: Slow UPADTE, compared to INSERT
Date
Msg-id [email protected]
Whole thread Raw
In response to Re: Slow UPADTE, compared to INSERT  (Ivar Zarans <[email protected]>)
Responses Re: Slow UPADTE, compared to INSERT
List pgsql-performance
On Thursday 04 December 2003 19:51, Ivar Zarans wrote:
>
> My second tests were done with temporary table and update query as:
> "UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM
> temptable)". It is still slower than INSERT, but more or less
> acceptable. Compared to my first tests overall processing time dropped
> from 1 hour and 20 minutes to 16 minutes.

Ah - it's probably not the update but the IN. You can rewrite it using PG's
non-standard FROM:

UPDATE t1 SET status='done' FROM t_tmp WHERE t1.rec_id = t_tmp.rec_id;

Now that doesn't explain why the update is taking so long. One fifth of a
second is extremely slow. Are you certain that the index is being used?

--
  Richard Huxton
  Archonet Ltd

pgsql-performance by date:

Previous
From: Richard Huxton
Date:
Subject: Re: tuning questions
Next
From: "Matthew T. O'Connor"
Date:
Subject: Re: autovacuum daemon stops doing work after about an hour