From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
---|---|
To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, David Rowley <dgrowley(at)gmail(dot)com> |
Subject: | Re: Removing useless DISTINCT clauses |
Date: | 2018-03-22 05:58:32 |
Message-ID: | CAKJS1f_KPr355Mxh+iy7GW586MN4=BTP2HUobc5Z83nct4=mTQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 21 March 2018 at 16:29, Melanie Plageman <melanieplageman(at)gmail(dot)com> wrote:
> For a small performance hit but an improvement in readability, the length check
> can be moved from the individual group by and distinct clause checks into the
> helper function
>
> if (list_length(parse->distinctClause) < 2)
> return;
>
> and
>
> if (list_length(parse->groupClause) < 2)
> return;
>
> can be moved into `remove_functionally_dependent_clauses`
I remember thinking about this when writing, and I think I ended up
doing the check earlier as I thought that having 1 GROUP BY clause
item would be the most common case, so it seems like a good idea to
abort as early as possible in that case. That's most likely not the
case for DISTINCT.
I imagine it probably does not make that much difference anyway, so
I've moved it into the remove_functionally_dependent_clauses()
function, as mentioned.
> The main helper function that is added `remove_functionally_dependent_clauses`
> uses one style of comment--with the name of the function and then the rest of
> the description indented which is found some places in the code,
> /*
> * remove_functionally_dependent_clauses
> * Processes clauselist and removes any items which are deemed to be
> * functionally dependent on other clauselist items.
> *
> * If any item from the list can be removed, then a new list is built which
> * does not contain the removed items. If no item can be removed then the
> * original list is returned.
> */
>
> while other helper functions in the same file use a different style--all lines
> flush to the side with a space. I'm not sure which is preferred
You might have a point, but remove_useless_groupby_columns already
does it this way, so I don't think changing that is a good idea.
> The new status of this patch is: Waiting on Author
Thanks for reviewing this. I've attached an updated patch. I'll set
back to waiting for review again.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachment | Content-Type | Size |
---|---|---|
remove_useless_distinct_clauses_v4.patch | application/octet-stream | 12.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavan Deolasee | 2018-03-22 06:29:14 | Re: Faster inserts with mostly-monotonically increasing values |
Previous Message | Ashutosh Bapat | 2018-03-22 04:36:07 | Re: [HACKERS] Partition-wise aggregation/grouping |