RE: [Patch] Use *other* indexes on the subscriber when REPLICA IDENTITY is FULL

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Peter Smith' <smithpb2250(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Önder Kalacı <onderkalaci(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: [Patch] Use *other* indexes on the subscriber when REPLICA IDENTITY is FULL
Date: 2023-07-12 07:06:55
Message-ID: TYAPR01MB5866B4F938ADD7088379633CF536A@TYAPR01MB5866.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Peter,

Thanks for giving comment.

>
> 1.
> FYI, this patch also needs some minor PG docs updates [1] because
> section "31.1 Publication" currently refers to only btree - e.g.
> "Candidate indexes must be btree, non-partial, and have..."
>
> (this may also clash with Sawada-san's other thread as previously mentioned)

Fixed that, but I could not find any other points. Do you have in mind others?
I checked related commits like 89e46d and adedf5, but only the part was changed.

> Commit message
>
> 2.
> Moreover, BRIN and GIN indexes do not implement "amgettuple".
> RelationFindReplTupleByIndex()
> assumes that tuples will be fetched one by one via
> index_getnext_slot(), but this
> currently requires the "amgetuple" function.
>
> ~
>
> Typo:
> /"amgetuple"/"amgettuple"/

Fixed.

> src/backend/executor/execReplication.c
>
> 3.
> + * 2) Moreover, BRIN and GIN indexes do not implement "amgettuple".
> + * RelationFindReplTupleByIndex() assumes that tuples will be fetched one by
> + * one via index_getnext_slot(), but this currently requires the "amgetuple"
> + * function. To make it use index_getbitmap() must be used, which fetches all
> + * the tuples at once.
> + */
> +int
>
> 3a.
> Typo:
> /"amgetuple"/"amgettuple"/

Per suggestion from Amit [1], the paragraph was removed.

> 3b.
> I think my previous comment about this comment was misunderstood. I
> was questioning why that last sentence ("To make it...") about
> "index_getbitmap()" is even needed in this patch. I thought it may be
> overreach to describe details how to make some future enhancement that
> might never happen.

Removed.

> src/backend/replication/logical/relation.c
>
> 4. IsIndexUsableForReplicaIdentityFull
>
> IsIndexUsableForReplicaIdentityFull(IndexInfo *indexInfo)
> {
> - bool is_btree = (indexInfo->ii_Am == BTREE_AM_OID);
> - bool is_partial = (indexInfo->ii_Predicate != NIL);
> - bool is_only_on_expression = IsIndexOnlyOnExpression(indexInfo);
> + bool is_suitable_type;
> + bool is_partial;
> + bool is_only_on_expression;
>
> - return is_btree && !is_partial && !is_only_on_expression;
> + /* Check whether the index is supported or not */
> + is_suitable_type = ((get_equal_strategy_number_for_am(indexInfo->ii_Am)
> + != InvalidStrategy));
> +
> + is_partial = (indexInfo->ii_Predicate != NIL);
> + is_only_on_expression = IsIndexOnlyOnExpression(indexInfo);
> +
> + return is_suitable_type && !is_partial && !is_only_on_expression;
>
> 4a.
> The code can be written more optimally, because if it is deemed
> already that 'is_suitable_type' is false, then there is no point to
> continue to do the other checks and function calls.

Right, is_suitable_type is now removed.

> 4b.
>
> + /* Check whether the index is supported or not */
> + is_suitable_type = ((get_equal_strategy_number_for_am(indexInfo->ii_Am)
> + != InvalidStrategy));
>
> The above statement has an extra set of nested parentheses for some reason.

This part was removed per above comment.

> src/backend/utils/cache/lsyscache.c
>
> 5.
> /*
> * get_opclass_method
> *
> * Returns the OID of the index access method operator class is for.
> */
> Oid
> get_opclass_method(Oid opclass)
>
> IMO the comment should be worded more like the previous one in this source file.
>
> SUGGESTION
> Returns the OID of the index access method the opclass belongs to.

Fixed.

[1]: https://www.postgresql.org/message-id/CAA4eK1%2B%2BR3WSfsGH0yFR9WEbkDfF__OccADR7qXDnHGTww%2BkvQ%40mail.gmail.com

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
v5-0001-Allow-the-use-Hash-index-when-REPLICA-IDENTITY-FU.patch application/octet-stream 14.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-07-12 07:07:45 RE: [Patch] Use *other* indexes on the subscriber when REPLICA IDENTITY is FULL
Previous Message Michael Paquier 2023-07-12 07:05:17 Re: Support to define custom wait events for extensions