public inbox for [email protected]  
help / color / mirror / Atom feed
From: Amit Kapila <[email protected]>
To: Peter Smith <[email protected]>
Cc: Önder Kalacı <[email protected]>
Cc: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Cc: Marco Slot <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Date: Tue, 7 Mar 2023 17:39:55 +0530
Message-ID: <CAA4eK1JsVv3zA9ca8E_EdYXFyyRCsod+iD05CzcRT6knbFCfiA@mail.gmail.com> (raw)
In-Reply-To: <CAHut+PvHQKqyL9np9dA2E5Lr9tj-8yPTo7nMD-6quUWY6Lhpgg@mail.gmail.com>
References: <OSZPR01MB63105BD4B03B3C1FBFCC7E6CFD249@OSZPR01MB6310.jpnprd01.prod.outlook.com>
	<CACawEhWdoiaXwKjn5ZfAKF_Toz=t1aqT1ewHmJLRnXmKOQKwyg@mail.gmail.com>
	<OS3PR01MB62754E945BD95A9B2A1164789E289@OS3PR01MB6275.jpnprd01.prod.outlook.com>
	<CACawEhXBtt9aMoU0j6funj-s+CW+e8HMFCGz30gyEwLazXB_1w@mail.gmail.com>
	<OSZPR01MB63109FF52120649EECACC7AEFD2A9@OSZPR01MB6310.jpnprd01.prod.outlook.com>
	<CACawEhUUHcSVhp-bODSAnYNUQHY=4gvY29DXM=yuphgrkcqqmQ@mail.gmail.com>
	<CACawEhX6TvX+j8EpcpCKvnMGao8Gcp8W43Sgc87pg9o6-Xbf2Q@mail.gmail.com>
	<[email protected]>
	<CACawEhV68Ry7BGJV150xsUskJPa88rpOf3zo_OcA_MpSWGQobQ@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAFMSG9E7_JgnaBj1f_jU4dEmOnL=K6UyBAPR7eZ0NukUcR2L9g@mail.gmail.com>
	<CACawEhUxEfVr64ywC0sj7nDwFg=vR30qehNoqSDcx6VV2=B_Lw@mail.gmail.com>
	<CAA4eK1L6P8hM+17fNyWogSnueTJebvZUX7YseL54HSFpX_0m_A@mail.gmail.com>
	<CACawEhUN=+vjY0+4q416-rAYx6pw-nZMHQYsJZCftf9MjoPN3w@mail.gmail.com>
	<CAA4eK1LhQWmFDvFHpO6yR-E4iL4ekUuSRwTw44dH9rMvpdu_hA@mail.gmail.com>
	<OSZPR01MB63103A4AFBBA56BAF8AE7FAAFDA39@OSZPR01MB6310.jpnprd01.prod.outlook.com>
	<CAA4eK1JOq0_r=LwYcqZ+8wufyg9NAeJBSCPbavmGES512pOeAQ@mail.gmail.com>
	<CACawEhV8X88dDxL+LYs9X=qGh+en1nVjNSevXcQPVuSnN+d2Pg@mail.gmail.com>
	<CACawEhUU8MgaCCLeLmcZe_XkOYnLEg9myWbsRZTogp_R8Jx02Q@mail.gmail.com>
	<CAA4eK1LRqn=-X2rDS4T_-UyiwdEnfSjz+2qRLoBJ6sMTaYga3A@mail.gmail.com>
	<CACawEhUQjxYU=UAamdnfaJU0uGJFXzhxrOT-km343kZYpeCGfw@mail.gmail.com>
	<CAA4eK1LPVqhuUkbHbCXDuQAvCvLA_qeCmg3WkOA3ZKBx1sh8dQ@mail.gmail.com>
	<CACawEhVk9_eSfbyEB-ej2N4FH2ZS7zc4mwXRGQWxA5LbKD+xww@mail.gmail.com>
	<CAHut+PtS5XpCM_wUXwJHLBOBVgZ8E=T8JtYsXHUQCzWASUyY2A@mail.gmail.com>
	<CACawEhVGnX_UBGMjn=rtZAgi03mWBujVFjukLhvFbk4Zjvi+dQ@mail.gmail.com>
	<CAHut+Pv6KaBUdJ5JfFPQn8=yYs3aOvbL4xbAtH+HX+i3uJ+p3g@mail.gmail.com>
	<CACawEhX_n8JcmKty0hFeStbTa5OFpn40sPM=4zontkN0tSgOZg@mail.gmail.com>
	<CAHut+PuHkYcg=BX1nBNNUxU0eRaQj+Xh6LaowA937W9MvuDACw@mail.gmail.com>
	<CAA4eK1+LhuGqWM_neQ5Se27o0zNw=iAQriTLt=RPq92W54ggXQ@mail.gmail.com>
	<CAHut+PvHQKqyL9np9dA2E5Lr9tj-8yPTo7nMD-6quUWY6Lhpgg@mail.gmail.com>

On Tue, Mar 7, 2023 at 3:00 PM Peter Smith <[email protected]> wrote:
>
> On Tue, Mar 7, 2023 at 8:01 PM Amit Kapila <[email protected]> wrote:
> >
> > On Tue, Mar 7, 2023 at 1:19 PM Peter Smith <[email protected]> wrote:
> > >
> > > Let me give an example to demonstrate why I thought something is fishy here:
> > >
> > > Imagine rel has a (non-default) REPLICA IDENTITY with Oid=1111.
> > > Imagine the same rel has a PRIMARY KEY with Oid=2222.
> > >
> > > ---
> > >
> > > +/*
> > > + * Get replica identity index or if it is not defined a primary key.
> > > + *
> > > + * If neither is defined, returns InvalidOid
> > > + */
> > > +Oid
> > > +GetRelationIdentityOrPK(Relation rel)
> > > +{
> > > + Oid idxoid;
> > > +
> > > + idxoid = RelationGetReplicaIndex(rel);
> > > +
> > > + if (!OidIsValid(idxoid))
> > > + idxoid = RelationGetPrimaryKeyIndex(rel);
> > > +
> > > + return idxoid;
> > > +}
> > > +
> > > +/*
> > > + * Given a relation and OID of an index, returns true if the
> > > + * index is relation's replica identity index or relation's
> > > + * primary key's index.
> > > + *
> > > + * Returns false otherwise.
> > > + */
> > > +bool
> > > +IdxIsRelationIdentityOrPK(Relation rel, Oid idxoid)
> > > +{
> > > + Assert(OidIsValid(idxoid));
> > > +
> > > + return GetRelationIdentityOrPK(rel) == idxoid;
> > > +}
> > > +
> > >
> > >
> > > So, according to the above function comment/name, I will expect
> > > calling IdxIsRelationIdentityOrPK passing Oid=1111 or Oid-2222 will
> > > both return true, right?
> > >
> > > But AFAICT
> > >
> > > IdxIsRelationIdentityOrPK(rel, 1111) --> GetRelationIdentityOrPK(rel)
> > > returns 1111 (the valid oid of the RI) --> 1111 == 1111 --> true;
> > >
> > > IdxIsRelationIdentityOrPK(rel, 2222) --> GetRelationIdentityOrPK(rel)
> > > returns 1111 (the valid oid of the RI) --> 1111 == 2222 --> false;
> > >
> > > ~
> > >
> > > Now two people are telling me this is OK, but I've been staring at it
> > > for too long and I just don't see how it can be. (??)
> > >
> >
> > The difference is that you are misunderstanding the intent of this
> > function. GetRelationIdentityOrPK() returns a "replica identity index
> > oid" if the same is defined, else return PK, if that is defined,
> > otherwise, return invalidOid. This is what is expected by its callers.
> > Now, one can argue to have a different function name and that may be a
> > valid argument but as far as I can see the function does what is
> > expected from it.
> >
>
> Sure, but I am questioning the function IdxIsRelationIdentityOrPK, not
> GetRelationIdentityOrPK.
>

The intent of IdxIsRelationIdentityOrPK() is as follows: Returns true
for the following conditions (a) if the given index OID is the same as
replica identity (when the same is defined); else (if replica identity
is not defined then (b)) (b) if the given OID is the same as PK.
Returns false otherwise. Feel free to propose any better function name
or if you think comments can be changed which makes it easier to
understand.

-- 
With Regards,
Amit Kapila.






view thread (23+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
  In-Reply-To: <CAA4eK1JsVv3zA9ca8E_EdYXFyyRCsod+iD05CzcRT6knbFCfiA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox