On 05/16/2016 12:41 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?
I would say that depends on how you are creating the temp table:
I'm presently using them without an "ON COMMIT" clause - they live until the end of the script/session/transaction (which here are all the same).
So within-transaction storage usage would be controllable making the use of BEGIN at least potentially meaningful - as long rollbacks or commits are used and more than one transaction is used to isolate the different parts.
The lack of auto-analyze is something to keep in mind (but haven't been bit by it yet so getting it to stick in memory is more difficult) in either case...though present usage involves sequential scans anyway.
Thanks!
David J.