Re: Marginal performance improvement: replace bms_first_member loops

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Marginal performance improvement: replace bms_first_member loops
Date: 2014-11-28 19:18:10
Message-ID: 5102.1417202290@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> A while back when I was benchmarking the planner time during my trials with
> anti/semi join removals, I wrote a patch to change the usage pattern for
> cases such as:

> if (bms_membership(a) != BMS_SINGLETON)
> return; /* nothing to do */
> singleton = bms_singleton_member(a);
> ...

> Into:

> if (!bms_get_singleton(a, &singleton))
> return; /* nothing to do */
> ...

> Which means 1 function call and loop over the bitmapset, rather than 2
> function
> calls and 2 loops over the set when the set is a singleton.

I went ahead and committed this with some cosmetic adjustments.
I'm not sure about there being any performance win in existing use-cases,
but it seems worth doing on notational grounds anyway.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2014-11-28 20:44:17 Re: no test programs in contrib
Previous Message Andres Freund 2014-11-28 18:01:02 Re: no test programs in contrib