Re: Aggregate leads to superfluous projection from the scan - Mailing list pgsql-hackers

From Zhihong Yu
Subject Re: Aggregate leads to superfluous projection from the scan
Date
Msg-id CALNJ-vQN-Zy9oqQnK5jEsg3jAX2YqdKJu4jx9akdousOxkVX=g@mail.gmail.com
Whole thread Raw
In response to Aggregate leads to superfluous projection from the scan  (Zhihong Yu <zyu@yugabyte.com>)
Responses Re: Aggregate leads to superfluous projection from the scan
List pgsql-hackers


On Fri, Jul 8, 2022 at 9:40 AM Zhihong Yu <zyu@yugabyte.com> wrote:
Hi,
Here is the query which involves aggregate on a single column:


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 past.
If so, what was the discussion around this topic ?

Thanks
Hi,
With the patch, I was able to get the following output:

 explain (analyze, verbose) /*+ IndexScan(t) */select count(fire_year) from fires t where objectid <= 2000000;
                                                              QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=119.00..119.01 rows=1 width=8) (actual time=9.453..9.453 rows=1 loops=1)
   Output: count(fire_year)
   ->  Index Scan using fires_pkey on public.fires t  (cost=0.00..116.50 rows=1000 width=4) (actual time=9.432..9.432 rows=0 loops=1)
         Output: fire_year
         Index Cond: (t.objectid <= 2000000)
 Planning Time: 52.598 ms
 Execution Time: 13.082 ms

Please pay attention to the column list after `Output:`

Tom:
Can you take a look and let me know what I may have missed ?

Thanks
Attachment

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: remove more archiving overhead
Next
From: Ibrar Ahmed
Date:
Subject: Re: explain analyze rows=%.0f