diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-01-29 10:40:22 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-01-29 10:43:33 +0200 |
commit | c9d7dbacd387ab3814bc6b38010a9e72a02ea4f5 (patch) | |
tree | e785a23531d42bcfc482f0f6049de00b9ce3337e /src | |
parent | fd4ced5230162b50a5c9d33b4bf9cfb1231aa62e (diff) | |
download | postgresql-c9d7dbacd387ab3814bc6b38010a9e72a02ea4f5.tar.gz postgresql-c9d7dbacd387ab3814bc6b38010a9e72a02ea4f5.zip |
Skip truncating ON COMMIT DELETE ROWS temp tables, if the transaction hasn't
touched any temporary tables.
We could try harder, and keep track of whether we've inserted to any temp
tables, rather than accessed them, and which temp tables have been inserted
to. But this is dead simple, and already covers many interesting scenarios.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/tablecmds.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 6bc056bbc33..1d5e0c646a4 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -10124,7 +10124,13 @@ PreCommit_on_commit_actions(void) /* Do nothing (there shouldn't be such entries, actually) */ break; case ONCOMMIT_DELETE_ROWS: - oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid); + /* + * If this transaction hasn't accessed any temporary + * relations, we can skip truncating ON COMMIT DELETE ROWS + * tables, as they must still be empty. + */ + if (MyXactAccessedTempRel) + oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid); break; case ONCOMMIT_DROP: { |