From: 范国腾 <fanguoteng@highgo.com>
To: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Where to change the column width in RelOptInfo data
Date: Wed, 25 Jul 2018 01:29:58 +0000
Message-ID: <f372513e8bd843d6a424f951ea14dfa9@EX01.highgo.com> (raw)
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=#
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: fanguoteng@highgo.com, pgsql-admin@lists.postgresql.org
Subject: Re: Where to change the column width in RelOptInfo data
In-Reply-To: <f372513e8bd843d6a424f951ea14dfa9@EX01.highgo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox