On 24 January 2016 at 00:56, Julien Rouhaud <julien.rouh...@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.

 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to