On 23/01/2016 14:51, David Rowley wrote:
> On 24 January 2016 at 00:56, Julien Rouhaud <julien.rouhaud@dalibo.com> wrote:
>> I wonder if in remove_useless_groupby_columns(), in the foreach loop you
>> could change the
>>
>> + if (bms_subset_compare(pkattnos, relattnos) == BMS_SUBSET1)
>> + {
>>
>> by something like
>>
>>
>> + if (bms_num_members(relattnos) <= bms_num_members(pkattnos))
>> + continue;
>> +
>> + if (bms_is_subset(pkattnos, relattnos))
>> + {
>>
>>
>> which may be cheaper.
>
> Thanks for looking over this again.
>
> I actually had that part written quite a few different ways before I
> finally decided to use bms_subset_compare. I didn't benchmark, but I
> thought 1 function call was better than 2, as I had it as
> bms_is_subset(pkattnos, relattnos) && !bms_is_subset(relattnos,
> pkattnos), and again with !bms_equal() instead of the 2nd subset test.
> I figured 1 function call was better than 2, so finally settled on
> bms_subset_compare(). I'm thinking that 3 function calls likely won't
> make things better. I can't imagine it's going to cost much either
> way, so I doubt it's worth trying to check whats faster. Although the
> thing about bms_num_members() is that it's going to loop over each
> word in the bitmap no matter what, whereas a subset check can abort
> early in some cases.
>
>
FWIW, this code was simplified example. bms_num_members(relattnos) is
already called a few lines before, so it'd be 1 function call against 2
function calls (and a var assignment).
--
Julien Rouhaud
http://dalibo.com - http://dalibo.org