[HACKERS] Print correct startup cost for the group aggregate. - Mailing list pgsql-hackers

From Rushabh Lathia
Subject [HACKERS] Print correct startup cost for the group aggregate.
Date
Msg-id CAGPqQf099_D2EELO3Fc28Zpb=6Q4m0CHP8EUGHAunUU1P1Zn7A@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] Print correct startup cost for the group aggregate.  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
List pgsql-hackers
Hi,

While reading through the cost_agg() I found that startup cost for the
group aggregate is not correctly assigned. Due to this explain plan is
not printing the correct startup cost.

Without patch:

postgres=# explain select aid, sum(abalance) from pgbench_accounts where filler like '%foo%' group by aid;
                                     QUERY PLAN                                     
-------------------------------------------------------------------------------------
 GroupAggregate  (cost=81634.33..85102.04 rows=198155 width=12)
   Group Key: aid
   ->  Sort  (cost=81634.33..82129.72 rows=198155 width=8)
         Sort Key: aid
         ->  Seq Scan on pgbench_accounts  (cost=0.00..61487.89 rows=198155 width=8)
               Filter: (filler ~~ '%foo%'::text)
(6 rows)

With patch:

postgres=# explain select aid, sum(abalance) from pgbench_accounts where filler like '%foo%' group by aid;
                                     QUERY PLAN                                     
-------------------------------------------------------------------------------------
 GroupAggregate  (cost=82129.72..85102.04 rows=198155 width=12)
   Group Key: aid
   ->  Sort  (cost=81634.33..82129.72 rows=198155 width=8)
         Sort Key: aid
         ->  Seq Scan on pgbench_accounts  (cost=0.00..61487.89 rows=198155 width=8)
               Filter: (filler ~~ '%foo%'::text)
(6 rows)

PFA patch to correct the same.

Regards,
Rushabh Lathia
Attachment

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: [HACKERS] logical decoding of two-phase transactions
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] Partitioned tables and relfilenode