Re: pg, mysql comparison with "group by" clause
От | Tom Lane |
---|---|
Тема | Re: pg, mysql comparison with "group by" clause |
Дата | |
Msg-id | 16344.1129168246@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: pg, mysql comparison with "group by" clause (Greg Stark <gsstark@mit.edu>) |
Список | pgsql-sql |
Greg Stark <gsstark@mit.edu> writes: > I think most MySQL users don't stumble on it, they learn it as the way > to handle the common use case when you join a master table against a > detail table and then want to aggregate all the detail records. In > standard SQL you have to write GROUP BY ... and list every single > column you need from the master table. Forcing the database to do a > lot of redundant comparisons and sort on uselessly long keys where in > fact you only really need it to sort and group by the primary key. Actually, if you're grouping by a table's primary key, the SQL99 spec says you shouldn't have to explicitly list the other columns from that table --- they are guaranteed to have unique values per group anyway. This is a single case in the "functional dependency" stuff. That verbiage is incredibly dense and I don't think we want to tackle all of it any time soon, but the primary-key case probably wouldn't be very hard to implement. We really ought to have this in TODO ... I'm sure it's been discussed before. regards, tom lane
В списке pgsql-sql по дате отправления: