On 21 March 2018 at 16:29, Melanie Plageman <melanieplage...@gmail.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
remove_useless_distinct_clauses_v4.patch
Description: Binary data