Functional dependencies and GROUP BY

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Functional dependencies and GROUP BY
Дата
Msg-id 1275935628.11078.12.camel@vanquo.pezone.net
обсуждение исходный текст
Ответы Re: Functional dependencies and GROUP BY  (Greg Stark <gsstark@mit.edu>)
Re: Functional dependencies and GROUP BY  (Hitoshi Harada <umi.tanuki@gmail.com>)
Re: Functional dependencies and GROUP BY  (Stephen Frost <sfrost@snowman.net>)
Re: Functional dependencies and GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Functional dependencies and GROUP BY  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
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 full functional dependency deduction rules
are pretty big and arcane, so I concentrated on getting a useful subset
working.  In particular:

When grouping by primary key, the other columns can be omitted, e.g.,

CREATE TABLE tab1 (a int PRIMARY KEY, b int);

SELECT a, b FROM tab1 GROUP BY a;

This is frequently requested by MySQL converts (and possibly others).

Also, when a column is compared with a constant, it can appear
ungrouped:

SELECT x, y FROM tab2 WHERE y = 5 GROUP BY x;

For lack of a better idea, I have made it so that merge-joinable
operators qualify as equality operators.  Better ideas welcome.

Other rules could be added over time (but I'm current not planning to
work on that myself).

At this point, this patch could use some review and testing with unusual
queries that break my implementation. ;-)


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: [BUGS] Invalid YAML output from EXPLAIN
Следующее
От: Greg Smith
Дата:
Сообщение: Re: [BUGS] Invalid YAML output from EXPLAIN