diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2017-03-22 13:09:36 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2017-03-22 13:09:36 +0000 |
commit | 9b013dc238cefa2860b384a3fa016ad1ceb062e4 (patch) | |
tree | f73b6ad8859cd4e4df946691aba36680345ba195 /src/backend/commands/tablecmds.c | |
parent | 1148e22a82edc96172fc78855da392b6f0015c88 (diff) | |
download | postgresql-9b013dc238cefa2860b384a3fa016ad1ceb062e4.tar.gz postgresql-9b013dc238cefa2860b384a3fa016ad1ceb062e4.zip |
Improve performance of replay of AccessExclusiveLocks
A hot standby replica keeps a list of Access Exclusive locks for a top
level transaction. These locks are released when the top level transaction
ends. Searching of this list is O(N^2), and each transaction had to pay the
price of searching this list for locks, even if it didn't take any AE
locks itself.
This patch optimizes this case by having the master server track which
transactions took AE locks, and passes that along to the standby server in
the commit/abort record. This allows the standby to only try to release
locks for transactions which actually took any, avoiding the majority of
the performance issue.
Refactor MyXactAccessedTempRel into MyXactFlags to allow minimal additional
cruft with this.
Analysis and initial patch by David Rowley
Author: David Rowley and Simon Riggs
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 86329e5f9f2..3b28e8c34f6 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -12471,7 +12471,7 @@ PreCommit_on_commit_actions(void) * relations, we can skip truncating ON COMMIT DELETE ROWS * tables, as they must still be empty. */ - if (MyXactAccessedTempRel) + if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPREL)) oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid); break; case ONCOMMIT_DROP: |