From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Update table is much faster after copying it |
Date: | 2015-01-21 06:14:03 |
Message-ID: | 20150121061403.GA7882@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Miles Jordan <miles(dot)jordan(at)rea-group(dot)com> wrote:
> Hi,
>
> I have tables a and b each with around 12 million rows. I am running
> an update query to set the id of table b as an attribute of table a,
> and have an appropriate index on table b that EXPLAIN tells me should
> be used.
>
> The query takes 6 hours on an AWS db.r3.4xlarge. That seemed hugely
> excessive, so I copied table a into a new table using CREATE TABLE b
> AS SELECT * FROM a, and for completeness also added the same indexes
> and constraints.
>
> Now, when I run the update on table a, it finishes in 3 minutes, and
> produces the same result.
>
> Can anyone shed some light on why this might happen? I’ve played
there are 2 possible reasons: caching and maybe a lot of dead tuples
within the original table. Please check the on-disk-size of table a and
b.
Andreas
--
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°
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-01-21 07:40:29 | Re: BDR Error restarted |
Previous Message | Miles Jordan | 2015-01-21 03:56:09 | Update table is much faster after copying it |