extra TARGETENTRY when group by function( col )?

Поиск
Список
Период
Сортировка
От Craig Harris
Тема extra TARGETENTRY when group by function( col )?
Дата
Msg-id 20101222161336.8B85B1337990@mail.postgresql.org
обсуждение исходный текст
Ответы Re: extra TARGETENTRY when group by function( col )?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

Given:

 

            create table t1 ( c1 timestamp without time zone, c2 int );

            explain verbose select to_char ( c1, ‘<whatever>’ ) from t1 group by to_char ( c1, ‘<whatever>’ );

 

does any one know why the SEQSCAN node has TWO TARGETENTRYs?

 

Why do we project “c1” as well as “to_char( c1 … )” ?

 

---

 

For cases where we compute an aggregate, such as:

 

            select min(c1), to_char(c1,…) from t1 group by to_char( c1,…)

 

it would make (some kind of) sense to project out “c1”.

 

But can’t the planner/optimizer distinguish these cases on the basis that ‘min’ is an aggregate function and ‘to_char’ is not?

 

The planner seems to be computing a minimal target list of columns (no expressions) first.  Guess I’m asking why it isn’t replaced.

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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: Re: could not open relation...No such file or directory
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: could not open relation...No such file or directory