Peter Eisentraut <pete...@gmx.net> writes: > I have developed a patch that partially implements the "functional > dependency" feature that allows some columns to be omitted from the > GROUP BY clause if it can be shown that the columns are functionally > dependent on the columns in the group by clause and therefore guaranteed > to be unique per group.
The main objection to this is the same one I've had all along: it makes the syntactic validity of a query dependent on what indexes exist for the table. At minimum, that means that enforcing the check at parse time is the Wrong Thing. The var-compared-with-constant case seems like a big crock. Are we really required to provide such a thing per spec? I'm also fairly concerned about the performance of a check implemented this way --- it's going to do a lot of work, and do it over and over again as it traverses the query tree. At least some of that could be alleviated after you move the check to the planner, just by virtue of the index information already having been acquired ... but I'd still suggest expending more than no effort on caching the results. For instance, given "SELECT * FROM a_very_wide_table GROUP BY pk" you shouldn't have to prove more than once that a_very_wide_table is grouped by its PK. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers