diff options
author | Amit Kapila | 2023-03-15 03:06:38 +0000 |
---|---|---|
committer | Amit Kapila | 2023-03-15 03:19:04 +0000 |
commit | 89e46da5e511a6970e26a020f265c9fb4b72b1d2 (patch) | |
tree | 48e26a630ff3447eb2b129065396d70d2570a560 /doc | |
parent | 720de00af49d3d46cb5c9b4753b52215f5029ac9 (diff) |
Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber.
Using REPLICA IDENTITY FULL on the publisher can lead to a full table scan
per tuple change on the subscription when REPLICA IDENTITY or PK index is
not available. This makes REPLICA IDENTITY FULL impractical to use apart
from some small number of use cases.
This patch allows using indexes other than PRIMARY KEY or REPLICA
IDENTITY on the subscriber during apply of update/delete. The index that
can be used must be a btree index, not a partial index, and it must have
at least one column reference (i.e. cannot consist of only expressions).
We can uplift these restrictions in the future. There is no smart
mechanism to pick the index. If there is more than one index that
satisfies these requirements, we just pick the first one. We discussed
using some of the optimizer's low-level APIs for this but ruled it out
as that can be a maintenance burden in the long run.
This patch improves the performance in the vast majority of cases and the
improvement is proportional to the amount of data in the table. However,
there could be some regression in a small number of cases where the indexes
have a lot of duplicate and dead rows. It was discussed that those are
mostly impractical cases but we can provide a table or subscription level
option to disable this feature if required.
Author: Onder Kalaci, Amit Kapila
Reviewed-by: Peter Smith, Shi yu, Hou Zhijie, Vignesh C, Kuroda Hayato, Amit Kapila
Discussion: https://postgr.es/m/CACawEhVLqmAAyPXdHEPv1ssU2c=dqOniiGz7G73HfyS7+nGV4w@mail.gmail.com
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/sgml/logical-replication.sgml | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 1bd5660c87..6b0e300adc 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -132,7 +132,14 @@ certain additional requirements) can also be set to be the replica identity. If the table does not have any suitable key, then it can be set to replica identity <quote>full</quote>, which means the entire row becomes - the key. This, however, is very inefficient and should only be used as a + the key. When replica identity <quote>full</quote> 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, + the search on the subscriber side can be very inefficient, therefore + replica identity <quote>full</quote> should only be used as a fallback if no other solution is possible. If a replica identity other than <quote>full</quote> is set on the publisher side, a replica identity comprising the same or fewer columns must also be set on the subscriber |