X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C5D769FA61D for ; Tue, 18 Jul 2006 12:41:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 39971-01-3 for ; Tue, 18 Jul 2006 12:41:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linuxworld.com.au (unknown [203.34.46.50]) by postgresql.org (Postfix) with ESMTP id 01C2C9FB1E3 for ; Tue, 18 Jul 2006 09:23:10 -0300 (ADT) Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id k6ICMvJQ011583; Tue, 18 Jul 2006 22:22:57 +1000 Received: from localhost (swm@localhost) by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id k6ICMvMb011580; Tue, 18 Jul 2006 22:22:57 +1000 X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs Date: Tue, 18 Jul 2006 22:22:57 +1000 (EST) From: Gavin Sherry X-X-Sender: swm@linuxworld.com.au To: Rusty Conover cc: pgsql-performance@postgresql.org Subject: Re: Temporary table retains old contents on update eventually In-Reply-To: <891F88B2-B31D-4217-9CB9-51B23C84D89A@infogears.com> Message-ID: References: <891F88B2-B31D-4217-9CB9-51B23C84D89A@infogears.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/178 X-Sequence-Number: 20038 On Tue, 18 Jul 2006, Rusty Conover wrote: > Hi, > > It would seem that doing any changes on a temp table forces a copy of > the entire contents of the table to be retained in memory/disk. Is > this happening due to MVCC? Is there a way to change this behavior? > It could be very useful when you have really huge temp tables that > need to be updated a few times before they can be dropped. This is caused by our MVCC implementation. It cannot be easily changed. We rely on MVCC for two things: concurrency and rolling back of aborted commands. Without the latter, we couldn't support the following trivially: template1=# create temp table bar (i int); CREATE TABLE template1=# begin; BEGIN template1=# insert into bar values(1); INSERT 0 1 template1=# abort; ROLLBACK template1=# select * from bar; i --- (0 rows) It would be nice if we could special case temp tables because of the fact that concurrency does not come into the equation but I cannot see it happening without a generalised overwriting MVCC system. The only alternative in the mean time is to vacuum your temporary table(s) as part of your interaction with them. Thanks, Gavin