Re: Any difference between commit/rollback when only temp tables and \copy are used

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alan Hodgson <ahodgson(at)lists(dot)simkin(dot)ca>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Any difference between commit/rollback when only temp tables and \copy are used
Date: 2016-05-16 20:06:28
Message-ID: CAKFQuwZqp21PemR95tua8CyvaHDiQoF-980H4kB05evQBeM0Xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 16, 2016 at 3:56 PM, Alan Hodgson <ahodgson(at)lists(dot)simkin(dot)ca>
wrote:

> On Monday, May 16, 2016 03:41:23 PM David G. Johnston wrote:
> > I have a psql script that obtains data via the \copy command and loads it
> > into a temporary table. Additional work is performed possibly generating
> > additional temporary tables but never any "real" tables. Then the script
> > outputs, either to stdout or via \copy, the results.
> >
> > Does it matter whether I issue a ROLLBACK or a COMMIT at the of the
> > transaction? More basically: does it matter whether I issue a BEGIN?
> >
> > The script runs on Ubuntu inside a bash shell's heredoc.
> >
>
> Some things will complete faster if you use BEGIN to start, as PostgreSQL
> will
> otherwise issue an implicit BEGIN and COMMIT before and after every
> statement.
>
>
​Non-zero but minimal compared to the I/O hit.​ The slightly more
meaningful savings would be in lesser consumption of transaction id
values. Though both would probably only matter at scale.

> If you don't need anything saved at the end it probably doesn't matter if
> you
> use ROLLBACK or COMMIT.
>

​Yeah, without the front end of this being optimized for once you get to
the end you've already consumed the relevant resources and I suspect that
as far at the catalogs go those temp tables are just as good as rolledback
on session end.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-05-16 20:08:54 Re: Any difference between commit/rollback when only temp tables and \copy are used
Previous Message Adrian Klaver 2016-05-16 20:02:13 Re: Connections - Postgres 9.2