From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
---|---|
To: | Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 13:51:03 |
Message-ID: | CAKJS1f-21QHfQhQ7u8rd4u+N3zJP5vEhedzJUZYCWUHFXMjfJA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 24 January 2016 at 00:56, Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Fabien COELHO | 2016-01-23 14:18:57 | Re: pgbench stats per script & other stuff |
Previous Message | Jinhua Luo | 2016-01-23 13:22:25 | Re: insert/update performance |