psql scripts

From: Ian Harding <harding(dot)ian(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: psql scripts
Date: 2005-11-09 15:26:58
Message-ID: 725602300511090726j36bb4ddy97c8d66294503ffa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a file which is a long series of SQL commands. Creating
tables, copying in data, indexing, munging the data, intermittently
vacuuming to keep things moving.

I have usually run this big script like this:

nohup psql dbname < script.sql &

After upgrading to 8.0, the script to slow to a crawl after a while.
However, it works fine when run from inside a psql session like this

\i script.sql

All I can think of is that the entire script is running in one big
transaction, although there are no explicit BEGIN statements in it.

The man page for psql says, regarding the -c option

"If the command string contains multiple SQL commands, they are
processed in a single transaction, unless there are explicit
BEGIN/COMMIT commands included in the string to divide it into
multiple transactions. This is different from the behavior when the
same string is fed to psql's standard input."

implying that stdin is run exactly the same as \i.

That being the case, what could be causing my script to slow to a
crawl when redirected to psql, but run fine from inside psql with -i?

- Ian

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Csaba Nagy 2005-11-09 15:36:21 Re: Question on Insert / Update
Previous Message Keith C. Perry 2005-11-09 15:25:53 Re: clustering by partial indexes