RE: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Önder Kalacı' <onderkalaci@gmail.com>
Cc: "shiy.fnst@fujitsu.com" <shiy.fnst@fujitsu.com>, "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>, Marco Slot <marco.slot@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Amit Kapila <amit.kapila16@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-03-03T08:46:20Z
Lists: pgsql-hackers
Dear Önder, Thanks for updating the patch! I played with your patch and I confirmed that parallel apply worker and tablesync worker could pick the index in typical case. Followings are comments for v27-0001. Please ignore if it is fixed in newer one. execReplication.c ``` + /* Build scankey for every non-expression attribute in the index. */ ``` I think that single line comments should not terminated by ".". ``` + /* There should always be at least one attribute for the index scan. */ ``` Same as above. ``` +#ifdef USE_ASSERT_CHECKING + IndexInfo *indexInfo = BuildIndexInfo(idxrel); + + Assert(!IsIndexOnlyOnExpression(indexInfo)); +#endif ``` I may misunderstand, but the condition of usable index has alteady been checked when the oid was set but anyway the you confirmed the condition again before really using that, right? So is it OK not to check another assumption that the index is b-tree, non-partial, and one column reference? IIUC we can do that by adding new function like IsIndexUsableForReplicaIdentityFull() that checks these condition, and then call at RelationFindReplTupleByIndex() if idxIsRelationIdentityOrPK is false. 032_subscribe_use_index.pl ``` +# Testcase start: SUBSCRIPTION CREATE/DROP INDEX WORKS WITHOUT ISSUES ... +# Testcase end: SUBSCRIPTION RE-CALCULATES INDEX AFTER CREATE/DROP INDEX ``` There is still non-consistent case. Best Regards, Hayato Kuroda FUJITSU LIMITED
Commits
-
Add the testcases for 89e46da5e5.
- 805b821e77a3 16.0 landed
-
Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber.
- 89e46da5e511 16.0 landed
-
Rework query relation permission checking
- a61b1f74823c 16.0 cited
-
Generalize ri_RootToPartitionMap to use for non-partition children
- fb958b5da86d 16.0 cited
-
Add wait_for_subscription_sync for TAP tests.
- 0c20dd33db16 16.0 cited
-
Logical replication
- 665d1fad99e7 10.0 cited