Re: Removing Functionally Dependent GROUP BY Columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Removing Functionally Dependent GROUP BY Columns
Date: 2016-01-23 15:39:20
Message-ID: 15746.1453563560@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-01-23 17:08:40 Re: Proposal: Trigonometric functions in degrees
Previous Message Tom Lane 2016-01-23 15:36:15 Re: proposal: function parse_ident