Skip site navigation (1) Skip section navigation (2)

Re: Why Does UPDATE Take So Long?

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Why Does UPDATE Take So Long?
Date: 2008-09-30 19:20:52
Message-ID: 20080930192052.GA8842@tux (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Bill Thoen <bthoen(at)gisnet(dot)com> schrieb:

> Working with PG 8.1 I'm trying to update a char(4) column, and it's  
> taking a very long time; 15 minutes so far and no end in sight. From the  
> explain, it doesn't seem like it should take that long, and this column  
> is not indexed. Sure, there's 2.7 million records but it only takes a  
> few minutes to scan the whole file. Is there some special overhead I  
> should be aware of with an UPDATE? I VACUUMed and ANALYZEd first, too.
> Or am I just expecting too much?
> Here's the explain:
> explain UPDATE farms SET prog_year='2007';
>                           QUERY PLAN
> ----------------------------------------------------------------
> Seq Scan on farms  (cost=0.00..59144.07 rows=2772207 width=54)
> (1 row)

Please provide us an EXPLAIN ANALYSE. But without a WHERE-condition a
seq-scan are logical, and PG has to rewrite the whole table and the

Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

In response to

pgsql-general by date

Next:From: Jeff DavisDate: 2008-09-30 19:36:13
Subject: Re: Why Does UPDATE Take So Long?
Previous:From: Alan HodgsonDate: 2008-09-30 19:14:05
Subject: Re: Why Does UPDATE Take So Long?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group