Re: Functional dependencies and GROUP BY
Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>
From: Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Eisentraut <peter_e@gmx.net>, Hitoshi Harada <umi.tanuki@gmail.com>, pgsql-hackers@postgresql.org
Date: 2010-06-08T14:48:44Z
Lists: pgsql-hackers
On 6/8/10 5:21 PM +0300, Tom Lane wrote: > Peter Eisentraut<peter_e@gmx.net> writes: >> On tis, 2010-06-08 at 09:59 +0900, Hitoshi Harada wrote: >>> In addition, what if y is implicitly a constant? For example, >>> >>> SELECT x, y FROM tab2 WHERE y = a AND a = 5 GROUP BY x; > >> Yes, as I said, my implementation is incomplete in the sense that it >> only recognizes some functional dependencies. To recognize the sort of >> thing you show, you would need some kind of complex deduction or proof >> engine, and that doesn't seem worthwhile, at least for me, at this >> point. > > The question is why bother to recognize *any* cases of this form. > I find it really semantically ugly to have the parser effectively > doing one deduction of this form when the main engine for that type > of deduction is elsewhere; so unless there is a really good argument > why we have to do this case (and NOT "it was pretty easy"), I don't > want to do it. > > As far as I recall, at least 99% of the user requests for this type > of behavior, maybe 100%, would be satisfied by recognizing the > group-by-primary-key case. So I think we should do that and be happy. +1 Regards, Marko Tiikkaja