Re: Autocommit off in psql??

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Paul Tomblin <ptomblin(at)xcski(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Autocommit off in psql??
Date: 2001-05-23 02:09:09
Message-ID: 20010523120909.B16297@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 22, 2001 at 08:18:31PM -0400, Paul Tomblin wrote:
> Quoting Neil Conway (nconway(at)klamath(dot)dyndns(dot)org):
> > Yes, just start an explicit transaction with "BEGIN" -- this disables
> > autocommit (so when you want to commit your transaction, you'll need
> > to do "COMMIT" by hand).
>
> That brings to mind a couple of questions I had:
>
> Can I just open a transaction, delete 100,000 rows in three tables, add
> back 100,000 rows in three tables, and then end the transaction? Even if
> it takes two hours and 5,000 lines of Perl code to do it? If so, how much
> disk space am I going to need? Would double the current used amount do
> it? And should I vacuum immediately afterwards?

Yes, absolutly. We do that here quite a bit so that if there a bug in the
program and it falls over, the database rolls back and we can fix it and
just rerun the program without worrying about the data.

In fact, sometimes for testing I comment out the last commit until the
program runs to completion with the proper debug output.

The amount of disk space is exactly the same as without a transaction.
Probably however much space you think 200,000 rows will take up. A vacuum is
recommened anytime you play with that much data.

The only issue is that transactions can't be nested but that shouldn't be a
problem. Also, it's possible that the transaction may block other queries on
the database but someone with more knowledge than me will have to answer
that.

--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Glenn Wittrock 2001-05-23 02:58:01 pg_dump fails, data integrity imperfect
Previous Message Martijn van Oosterhout 2001-05-23 01:59:13 Re: Estimating costs (was Functional Indices)