Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Tom Lane
Zhihong Yu writes: > I was looking at the following comment in createplan.c : > * For table scans, rather than using the relation targetlist (which is > * only those Vars actually needed by the query), we prefer to generate > a > * tlist containing all Vars in order. This will all

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 12:48 PM Zhihong Yu wrote: > > > On Fri, Jul 8, 2022 at 12:30 PM Tom Lane wrote: > >> Ibrar Ahmed writes: >> > I give a quick look and I think in case whenever data is extracted from >> the >> > heap it shows all the columns. Therefore when columns are extracted from >> >

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 12:30 PM Tom Lane wrote: > Ibrar Ahmed writes: > > I give a quick look and I think in case whenever data is extracted from > the > > heap it shows all the columns. Therefore when columns are extracted from > > the index only it shows the indexed column only. > > This is op

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Tom Lane
Ibrar Ahmed writes: > I give a quick look and I think in case whenever data is extracted from the > heap it shows all the columns. Therefore when columns are extracted from > the index only it shows the indexed column only. This is operating as designed, and I don't think that the proposed patch

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Ibrar Ahmed
On Fri, Jul 8, 2022 at 10:32 PM Zhihong Yu wrote: > > > On Fri, Jul 8, 2022 at 9:40 AM Zhihong Yu wrote: > >> Hi, >> Here is the query which involves aggregate on a single column: >> >> >> https://dbfiddle.uk/?rdbms=postgres_13&fiddle=44bfd8f6b6b5aad34d00d449c04c5a96 >> >> As you can see from `O

Re: Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
On Fri, Jul 8, 2022 at 9:40 AM Zhihong Yu wrote: > Hi, > Here is the query which involves aggregate on a single column: > > > https://dbfiddle.uk/?rdbms=postgres_13&fiddle=44bfd8f6b6b5aad34d00d449c04c5a96 > > As you can see from `Output:`, there are many columns added which are not > needed by th

Aggregate leads to superfluous projection from the scan

2022-07-08 Thread Zhihong Yu
Hi, Here is the query which involves aggregate on a single column: https://dbfiddle.uk/?rdbms=postgres_13&fiddle=44bfd8f6b6b5aad34d00d449c04c5a96 As you can see from `Output:`, there are many columns added which are not needed by the query executor. I wonder if someone has noticed this in the pa