Where to change the column width in RelOptInfo data

Поиск
Список
Период
Сортировка
Искать

Where to change the column width in RelOptInfo data

От:
范国腾 <fanguoteng@highgo.com>
Дата:

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=#

Re: Where to change the column width in RelOptInfo data

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
=?gb2312?B?t7a5+sza?=  writes:
> 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¡±.

I think you'd be better off doing that sort of thing in the rewriter
somewhere.  Wherever you tried to put it in the planner is clearly
too late.

			regards, tom lane

FAQ