Where to change the column width in RelOptInfo data

From: 范国腾 <fanguoteng(at)highgo(dot)com>
To: "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Where to change the column width in RelOptInfo data
Date: 2018-07-25 01:29:58
Message-ID: f372513e8bd843d6a424f951ea14dfa9@EX01.highgo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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=#

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Mariel Cherkassky 2018-07-25 07:22:08 Re: invalid value for parameter "client_encoding": "ISO_8859_8"
Previous Message Mariel Cherkassky 2018-07-24 13:58:54 Re: pg_authid has duplicated rows