pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Where to change the column width in RelOptInfo data
2+ messages / 2 participants
[nested] [flat]

* Where to change the column width in RelOptInfo data
@ 2018-07-25 01:29  范国腾 <fanguoteng@highgo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: 范国腾 @ 2018-07-25 01:29 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Where to change the column width in RelOptInfo data
@ 2018-07-25 14:35  Tom Lane <tgl@sss.pgh.pa.us>
  parent: 范国腾 <fanguoteng@highgo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-07-25 14:35 UTC (permalink / raw)
  To: 范国腾 <fanguoteng@highgo.com>; +Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

=?gb2312?B?t7a5+sza?= <fanguoteng@highgo.com> 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-07-25 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 01:29 Where to change the column width in RelOptInfo data 范国腾 <fanguoteng@highgo.com>
2018-07-25 14:35 ` Tom Lane <tgl@sss.pgh.pa.us>

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