Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s4tlB-001mnG-M4 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 May 2024 02:43:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s4tl8-004COc-FK for pgsql-hackers@arkaria.postgresql.org; Thu, 09 May 2024 02:43:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s4tl8-004COT-2c for pgsql-hackers@lists.postgresql.org; Thu, 09 May 2024 02:43:50 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s4tl2-0007Dl-9E for pgsql-hackers@lists.postgresql.org; Thu, 09 May 2024 02:43:49 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-de45385a1b4so380744276.3 for ; Wed, 08 May 2024 19:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715222623; x=1715827423; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0WYojJ+ib0tol33zp9kidStxOLvaBwRmTfM0xNGpYUw=; b=RctZYwFE2ek0RUt7/NIQH8wLyTitwmSaU64ggprwYSpRjfq5gYC3v/5NPDhbD9tHQf zFqiVpQR1LHFZwtqT7g+lcMasZClNWUy5h8bWaixH8IY7tp4Ggunp09Dc/APkZ6oabjb 05Gr2JQMls8ufktcoc7lYIdJZ9Uk1EGbcYrMY7BaBvAq1q7N9a5gWSCKLGFE+sClEjcN Qtn6wJNp7BitOHP2qqJ7zRRNSEq0LVSB7g9tiSB2jvSdSF1v4LgIyROTztWNKes6ENbb w6lQt/gkDlDATAPpkj1B0VmvFqQLcVQI0Id+NX0DCt+hkdCLRIc7IbptlRRgO31hvDw2 bQHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715222623; x=1715827423; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0WYojJ+ib0tol33zp9kidStxOLvaBwRmTfM0xNGpYUw=; b=bnrFEZB/gdf2KueRbfV2Ix5slwRJMlqetf9pOkEZNLlm/2HOvgH48LkUfSKRtmK72Q NBKSs+ViMLJ3NvD0Mtzta+M7P+WqmB17lGUKpRz1q8sYY8QmTDRnPkPpYuvjchbxSGTZ oSqCx5JtiQo/NN8OKJdf84T8fJG2UNr6LUMqHFlDpm5TUYh7TfnC5QXQDBBJTrz6Xmt8 +EoeZB2+fXZQjoLPIDc5HAr906nuw4yeikrVBrtBFFBT8KgCh4GndjEUGE1feTQarpbu HG79hZvprnGFZhkVwQOG62ZJE7UzOTT0rNKz0+dLRbSmIklX4rHKuEw/AXsiCNqBpU5U Ntew== X-Forwarded-Encrypted: i=1; AJvYcCWD2YfV+de4zkdXxPMjplah1LkmyQey9D2ODMA2hNo5akvU8GxhnX+MWz86vi9pNw/wAx0iBuhyEQHVGKvHpMPReLFGdEYfCHU8qmxRzQ7Ah7F3 X-Gm-Message-State: AOJu0YwdhsosWXeobyXrJtayk7HYPrGCCcFHcTls6aCPjDzJbEvq2c+m hNnpVlgpwWFz2yssdJLJxA3csSPY3/C0lZQqsjJTI9kBF1kIKRaQZBWv017c7lI2qmzjV3Lf+QE /FLRwRnLMefYwBnOG4lNrpdS+w5I= X-Google-Smtp-Source: AGHT+IF+zKa2we3F88HhkwNoH92X+58+IE9alqWLmJoFmApkcGi0cqLiPQahokD2lRitwewhMr+/CuhL+FXa3SYBGkM= X-Received: by 2002:a25:800e:0:b0:dda:a9cd:59c5 with SMTP id 3f1490d57ef6-debb9e2bb00mr4568082276.40.1715222622766; Wed, 08 May 2024 19:43:42 -0700 (PDT) MIME-Version: 1.0 References: <1e6ca7b3-98e6-46b2-9982-97f92c7523d8@dunslane.net> <76910.1715106055@sss.pgh.pa.us> <276516.1715121616@sss.pgh.pa.us> <279607.1715122556@sss.pgh.pa.us> <282081.1715123889@sss.pgh.pa.us> <815049.1715192644@sss.pgh.pa.us> <936562.1715208033@sss.pgh.pa.us> In-Reply-To: <936562.1715208033@sss.pgh.pa.us> From: Richard Guo Date: Thu, 9 May 2024 10:43:31 +0800 Message-ID: Subject: Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail. To: Tom Lane Cc: David Rowley , Andrew Dunstan , jian he , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000240fb80617fc630e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000240fb80617fc630e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 9, 2024 at 6:40=E2=80=AFAM Tom Lane wrote: > David Rowley writes: > > I'm fine with this one as it's the same as what I already mentioned > > earlier. I had imagined doing bms_del_member(bms_copy ... but maybe > > the compiler is able to optimise away the additional store. Likely, it > > does not matter much as pallocing memory likely adds far more overhead > > anyway. > > I actually wrote it that way to start with, but undid it after > noticing that the existing code in remove_rel_from_restrictinfo > does it in separate steps, and thinking that that was good for > both separation of concerns and a cleaner git history. I too > can't believe that an extra fetch will be noticeable compared > to the cost of the adjacent bms_xxx operations. I also think it seems better to do bms_copy in separate steps, not only because this keeps consistent with the existing code in remove_rel_from_restrictinfo, but also because we need to do bms_del_member twice for each lefthand/righthand relid set. Speaking of consistency, do you think it would improve the code's readability if we rearrange the code in remove_rel_from_query so that the modifications of the same relid set are grouped together, just like what we do in remove_rel_from_restrictinfo? I mean something like: sjinf->min_lefthand =3D bms_copy(sjinf->min_lefthand); sjinf->min_lefthand =3D bms_del_member(sjinf->min_lefthand, relid); sjinf->min_lefthand =3D bms_del_member(sjinf->min_lefthand, ojrelid); ... Thanks Richard --000000000000240fb80617fc630e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, May 9, 2024 at 6:40=E2=80=AFAM To= m Lane <tgl@sss.pgh.pa.us> w= rote:
David Rowl= ey <dgrowleyml= @gmail.com> writes:
> I'm fine with this one as it's the same as what I already ment= ioned
> earlier.=C2=A0 I had imagined doing bms_del_member(bms_copy ... but ma= ybe
> the compiler is able to optimise away the additional store. Likely, it=
> does not matter much as pallocing memory likely adds far more overhead=
> anyway.

I actually wrote it that way to start with, but undid it after
noticing that the existing code in remove_rel_from_restrictinfo
does it in separate steps, and thinking that that was good for
both separation of concerns and a cleaner git history.=C2=A0 I too
can't believe that an extra fetch will be noticeable compared
to the cost of the adjacent bms_xxx operations.

=
I also think it seems better to do bms_copy in separate steps, not onl= y
because this keeps consistent with the existing code in
remove_rel_= from_restrictinfo, but also because we need to do
bms_del_member twice f= or each lefthand/righthand relid set.

Speaking of consistency, do yo= u think it would improve the code's
readability if we rearrange the = code in remove_rel_from_query so that
the modifications of the same reli= d set are grouped together, just like
what we do in remove_rel_from_rest= rictinfo?=C2=A0 I mean something like:

=C2=A0 =C2=A0sjinf->min_le= fthand =3D bms_copy(sjinf->min_lefthand);
=C2=A0 =C2=A0sjinf->min_= lefthand =3D bms_del_member(sjinf->min_lefthand, relid);
=C2=A0 =C2= =A0sjinf->min_lefthand =3D bms_del_member(sjinf->min_lefthand, ojreli= d);

=C2=A0 =C2=A0...

Thanks
Richard
--000000000000240fb80617fc630e--