X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 33E4B9DD451 for ; Mon, 20 Mar 2006 19:22:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11788-07 for ; Mon, 20 Mar 2006 19:22:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 097DB9DD200 for ; Mon, 20 Mar 2006 19:22:43 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k2KNMj7E008910; Mon, 20 Mar 2006 18:22:45 -0500 (EST) To: "Craig A. James" cc: pgsql-performance@postgresql.org Subject: Re: update == delete + insert? In-reply-to: <441F3187.90506@modgraph-usa.com> References: <7F10D26ECFA1FB458B89C5B4B0D72C2B088286@sesrv12.wirelesscar.com> <441EC652.1010807@modgraph-usa.com> <441F3187.90506@modgraph-usa.com> Comments: In-reply-to "Craig A. James" message dated "Mon, 20 Mar 2006 14:49:43 -0800" Date: Mon, 20 Mar 2006 18:22:45 -0500 Message-ID: <8909.1142896965@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113] X-Spam-Score: 0.113 X-Spam-Level: X-Archive-Number: 200603/357 X-Sequence-Number: 17794 "Craig A. James" writes: > 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. No. The reason "drop column" is fast is that we make no attempt to remove the data from existing rows; we only mark the column's entry in the system catalogs as deleted. "add column" is only fast if you are adding a column with no default (a/k/a default NULL). In that case likewise we don't have to modify existing rows; the desired behavior falls out from the fact that the tuple access routines return NULL if asked to fetch a column beyond those existing in a particular tuple. You can read about the storage layout in http://developer.postgresql.org/docs/postgres/storage.html regards, tom lane