Where to change the column width in RelOptInfo data - Mailing list pgsql-admin

From 范国腾
Subject Where to change the column width in RelOptInfo data
Date
Msg-id f372513e8bd843d6a424f951ea14dfa9@EX01.highgo.com
Whole thread Raw
Responses Re: Where to change the column width in RelOptInfo data  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin

Hi,

 

I use a postgres extension plugin pg_strom to generate the plan. I select one column “avg(c_acctbal)” in the SQL, and the generated plan changes to select two column “c_acctbal, c_phone”.

 

When the plan executes, it need the width value of the two column(c_acctbal, c_phone) but I find the attr_widths field in RelOptInfo data only has the width of acctbal. The width of c_phone is 0.

 

I use the gdb to debug the function set_rel_width, it only set the the width of c_acctbal.

 

According to my understanding of the code, the RelOptInfo value is filled before the extension append a new path to the PlannerInfo, and it will not change even if the new plan change the targetlist length from 1 to 2. Is it correct?

 

If I want to change the code to add the width of c_phone in RelOptInfo->attr_widths, which place is good for change?

 

 

================================== The Case ===========================================

postgres=# set enable_seqscan=off;

SET

postgres=# explain select                                                                    

                       c_acctbal

                from

                        customer

                where

                        c_acctbal > (

                                select

                                        avg(c_acctbal)

                                from

                                        customer

                                where

                                        c_acctbal > 0.00

                                        and substring(c_phone from 1 for 2) in

                                                ('18')

                        );

                                             QUERY PLAN                                              

-----------------------------------------------------------------------------------------------------

Seq Scan on customer  (cost=10000004090.60..10000004161.35 rows=633 width=7)

   Filter: (c_acctbal > $0)

   InitPlan 1 (returns $0)

     ->  Aggregate  (cost=4090.59..4090.60 rows=1 width=32)

           ->  Custom Scan (GpuScan) on customer customer_1  (cost=4090.56..4090.56 rows=10 width=7)

                 Filter: ("substring"((c_phone)::text, 1, 2) = '18'::text)

                 GPU Projection: c_acctbal, c_phone

                 GPU Filter: (c_acctbal > 0.00)

(8 rows)

 

postgres=#

pgsql-admin by date:

Previous
From: Mariel Cherkassky
Date:
Subject: Re: pg_authid has duplicated rows
Next
From: Mariel Cherkassky
Date:
Subject: Re: invalid value for parameter "client_encoding": "ISO_8859_8"