Re: Removing Functionally Dependent GROUP BY Columns - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Removing Functionally Dependent GROUP BY Columns
Date
Msg-id 15746.1453563560@sss.pgh.pa.us
Whole thread Raw
In response to Re: Removing Functionally Dependent GROUP BY Columns  (Julien Rouhaud <julien.rouhaud@dalibo.com>)
List pgsql-hackers
Julien Rouhaud <julien.rouhaud@dalibo.com> writes:
> 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.

FWIW, I really doubt that would be cheaper.  The various flavors of
subset comparison are word-at-a-time bitmasking operations, but
bms_num_members has to grovel over individual bits; it's certain to
be more expensive than a subset test.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal: function parse_ident
Next
From: Tom Lane
Date:
Subject: Re: Proposal: Trigonometric functions in degrees