pgsql: Disable physical tlist if any Var would need multiple sortgroupr

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Disable physical tlist if any Var would need multiple sortgroupr
Дата
Msg-id E1b60Oh-0005hi-3D@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Disable physical tlist if any Var would need multiple sortgroupref labels.

As part of upper planner pathification (commit 3fc6e2d7f5b652b4) I redid
createplan.c's approach to the physical-tlist optimization, in which scan
nodes are allowed to return exactly the underlying table's columns so as
to save doing a projection step at runtime.  The logic was intentionally
more aggressive than before about applying the optimization, which is
generally a good thing, but Andres Freund found a case in which it got
too aggressive.  Namely, if any column is referenced more than once in
the parent plan node's sorting or grouping column list, we can't optimize
because then that column would need to have more than one ressortgroupref
label, and we only have space for one.

Add logic to detect this situation in use_physical_tlist(), and also add
some error checking in apply_pathtarget_labeling_to_tlist(), which this
example proves was being overly cavalier about whether what it was doing
made any sense.

The added test case exposes the problem only because we do not eliminate
duplicate grouping keys.  That might be something to fix someday, but it
doesn't seem like appropriate post-beta work.

Report: <20160526021235.w4nq7k3gnheg7vit@alap3.anarazel.de>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/aeb9ae6457865c8949641d71a9523374d843a418

Modified Files
--------------
src/backend/optimizer/plan/createplan.c       | 15 +++++++++++++--
src/backend/optimizer/util/tlist.c            | 23 +++++++++++++++++------
src/test/regress/expected/select_distinct.out | 24 ++++++++++++++++++++++++
src/test/regress/sql/select_distinct.sql      | 11 +++++++++++
4 files changed, 65 insertions(+), 8 deletions(-)


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: Fix typo in 9.5 release nodes
Следующее
От: Magnus Hagander
Дата:
Сообщение: pgsql: Make pg_dump error cleanly with -j against hot standby