Re: Microoptimization of Bitmapset usage in postgres_fdw

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: "Bossart, Nathan" <bossartn(at)amazon(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Microoptimization of Bitmapset usage in postgres_fdw
Date: 2018-06-17 17:23:19
Message-ID: 2EBD7A6C-013C-4570-B93E-4A0384623F78@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 17 Jun 2018, at 14:47, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Jun 14, 2018 at 08:14:54PM +0000, Bossart, Nathan wrote:
>> I'll go ahead and mark this as Ready for Committer.
>
> Another thing not mentioned on this thread is that bms_membership is
> faster than bms_num_members by design with many members, so this change
> makes sense to shave a couple of cycles.
>
> /*
> * bms_num_members - count members of set
> + *
> + * In situations where the exact count isn't required, bms_membership can be
> + * used to test if the set has 0, 1 or multiple members.
> */
> bms_membership is a couple of lines down, I am not sure I see much point
> in duplicating what's already present.

It is indeed a bit of a duplication, but the only reason this patch came to be
was that the original author of the instances in postgres_fdw had missed said
comment on bms_membership a few lines down.

> - if (bms_num_members(clauses_attnums) < 2)
> + if (bms_membership(clauses_attnums) != BMS_MULTIPLE)
> For this one, the comment above directly mentions that at least two
> attnums need to be present, so it seems to me that the current coding is
> easier to understand and intentional... So I would be incline to not
> change it.

I don’t have any strong feelings either way, and will leave that call to the
committer who picks this up. I agree that the current coding is easy to
understand but I don’t see this being much harder.

> I think that this should not go into the tree until REL_11_STABLE gets
> created though, so this will have to wait a bit.

100% agree.

cheers ./daniel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-06-17 17:29:34 Re: Query Rewrite for Materialized Views (Postgres Extension)
Previous Message Andrew Gierth 2018-06-17 15:52:56 Re: Slow planning time for simple query