v3-0001-Doc-clarify-the-conditions-of-usable-indexes-for-.patch
application/octet-stream
Filename: v3-0001-Doc-clarify-the-conditions-of-usable-indexes-for-.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v3-0001
Subject: Doc: clarify the conditions of usable indexes for REPLICA IDENTITY FULL tables.
| File | + | − |
|---|---|---|
| doc/src/sgml/logical-replication.sgml | 4 | 4 |
| src/backend/executor/execReplication.c | 3 | 3 |
| src/backend/replication/logical/relation.c | 4 | 3 |
From 2ff55c318971d34c68fb8a28b9acb97ab99bbf71 Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Fri, 7 Jul 2023 16:49:39 +0900
Subject: [PATCH v3] Doc: clarify the conditions of usable indexes for REPLICA
IDENTITY FULL tables.
Commit 89e46da5e allowed REPLICA IDENTIFY FULL tables to use an index
on the subscriber during apply of update/delete.
The source code comments are also updated accordingly.
Reviewed-by: Amit Kapila, Peter Smith
Discussion: https://postgr.es/m/CAD21AoDJjffEvUFKXT27Q5U8-UU9JHv4rrJ9Ke8Zkc5UPWHLvA@mail.gmail.com
Backpatch-through: 16
---
doc/src/sgml/logical-replication.sgml | 8 ++++----
src/backend/executor/execReplication.c | 6 +++---
src/backend/replication/logical/relation.c | 7 ++++---
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml
index c5de2040f7..92c3043303 100644
--- a/doc/src/sgml/logical-replication.sgml
+++ b/doc/src/sgml/logical-replication.sgml
@@ -134,10 +134,10 @@
to replica identity <literal>FULL</literal>, which means the entire row becomes
the key. When replica identity <literal>FULL</literal> is specified,
indexes can be used on the subscriber side for searching the rows. Candidate
- indexes must be btree, non-partial, and have at least one column reference
- (i.e. cannot consist of only expressions). These restrictions
- on the non-unique index properties adhere to some of the restrictions that
- are enforced for primary keys. If there are no such suitable indexes,
+ indexes must be btree, non-partial, and the leftmost index column must reference
+ a published table column (i.e. cannot consist of only expressions). These
+ restrictions on the non-unique index properties adhere to some of the restrictions
+ that are enforced for primary keys. If there are no such suitable indexes,
the search on the subscriber side can be very inefficient, therefore
replica identity <literal>FULL</literal> should only be used as a
fallback if no other solution is possible. If a replica identity other
diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c
index 9dd7168461..6f2a465133 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -47,9 +47,9 @@ static bool tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
*
* Returns how many columns to use for the index scan.
*
- * This is not generic routine, it expects the idxrel to be a btree, non-partial
- * and have at least one column reference (i.e. cannot consist of only
- * expressions).
+ * This is not generic routine, idxrel must be PK, RI, or an index that can be
+ * used for REPLICA IDENTITY FULL table (see FindUsableIndexForReplicaIdentityFull()
+ * for details).
*
* By definition, replication identity of a rel meets all limitations associated
* with that. Note that any other index could also meet these limitations.
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 57ad22b48a..8bc002cdfc 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -779,9 +779,10 @@ RemoteRelContainsLeftMostColumnOnIdx(IndexInfo *indexInfo, AttrMap *attrmap)
/*
* Returns the oid of an index that can be used by the apply worker to scan
- * the relation. The index must be btree, non-partial, and have at least
- * one column reference (i.e. cannot consist of only expressions). These
- * limitations help to keep the index scan similar to PK/RI index scans.
+ * the relation. The index must be btree, non-partial, and the leftmost column
+ * must reference a published table column (i.e. cannot consist of only
+ * expressions). These limitations help to keep the index scan similar to
+ * PK/RI index scans.
*
* Note that the limitations of index scans for replica identity full only
* adheres to a subset of the limitations of PK/RI. For example, we support
--
2.31.1