Re: Slow UPADTE, compared to INSERT
Richard Huxton <dev@archonet.com>
From: Richard Huxton <dev@archonet.com>
To: Ivar Zarans <iff@alcaron.ee>, pgsql-performance@postgresql.org
Date: 2003-12-04T20:23:36Z
Lists: 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