pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaime Casanova <systemguards@gmail.com>
To: Craig A. James <cjames@modgraph-usa.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: update == delete + insert?
Date: Mon, 20 Mar 2006 20:38:15 -0500
Message-ID: <c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com> (raw)
In-Reply-To: <441F3187.90506@modgraph-usa.com>
References: <7F10D26ECFA1FB458B89C5B4B0D72C2B088286@sesrv12.wirelesscar.com>
	<441EC652.1010807@modgraph-usa.com>
	<441F3187.90506@modgraph-usa.com>

On 3/20/06, Craig A. James <cjames@modgraph-usa.com> wrote:
> I've seen it said here several times that "update == delete + insert".  On the other hand, I've noticed that "alter table [add|drop] column ..." is remarkably fast, even for very large tables, which leads me to wonder whether each column's contents are in a file specifically for that column.
>
> My question: Suppose I have a very "wide" set of data, say 100 columns, and one of those columns will be updated often, but the others are fairly static.  I have two choices:
>
> Design 1:
>    create table a (
>      id integer,
>      frequently_updated  integer);
>
>    create table b(
>      id integer,
>      infrequently_updated_1 integer,
>      infrequently_updated_2 integer,
>      infrequently_updated_3 integer,
>      ... etc.
>      infrequently_updated_99 integer);
>
> Design 2:
>    create table c(
>      id integer,
>      frequently_updated  integer,
>      infrequently_updated_1 integer,
>      infrequently_updated_2 integer,
>      infrequently_updated_3 integer,
>      ... etc.
>      infrequently_updated_99 integer);
>
> If "update == delete + insert" is strictly true, then "Design 2" would be poor since 99 columns would be moved around with each update.  But if columns are actually stored in separate files, the Designs 1 and 2 would be essentially equivalent when it comes to vacuuming.
>
> Thanks,
> Craig
>

design 1 is normalized and better
design 2 is denormalized and a bad approach no matter the RDBMS

update does delete + insert, and vacuum is the way to recover the space

--
Atentamente,
Jaime Casanova

"What they (MySQL) lose in usability, they gain back in benchmarks, and that's
all that matters: getting the wrong answer really fast."
                           Randal L. Schwartz



view thread (7+ messages)  latest in thread

Message-ID: <c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com>
Permalink:  ../c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com/
Also on:    postgresql.org/message-id/c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: systemguards@gmail.com, cjames@modgraph-usa.com
  Subject: Re: update == delete + insert?
  In-Reply-To: <c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com>
  References: <7F10D26ECFA1FB458B89C5B4B0D72C2B088286@sesrv12.wirelesscar.com> <441EC652.1010807@modgraph-usa.com> <441F3187.90506@modgraph-usa.com> <c2d9e70e0603201738s6664b1fci1717188cce834a39@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox