Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi8Z2-0006hu-IB for pgsql-admin@arkaria.postgresql.org; Wed, 25 Jul 2018 01:26:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fi8Z0-00024Q-QH for pgsql-admin@arkaria.postgresql.org; Wed, 25 Jul 2018 01:26:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi8Z0-00024J-Hi for pgsql-admin@lists.postgresql.org; Wed, 25 Jul 2018 01:26:02 +0000 Received: from [124.133.18.218] (helo=ex01.highgo.com) by magus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fi8Yp-0003wc-4R for pgsql-admin@lists.postgresql.org; Wed, 25 Jul 2018 01:26:01 +0000 Received: from EX01.highgo.com (192.168.110.194) by EX01.highgo.com (192.168.110.194) with Microsoft SMTP Server (TLS) id 15.0.775.38; Wed, 25 Jul 2018 09:29:59 +0800 Received: from EX01.highgo.com ([192.168.110.194]) by EX01.highgo.com ([192.168.110.194]) with mapi id 15.00.0775.031; Wed, 25 Jul 2018 09:29:59 +0800 From: =?gb2312?B?t7a5+sza?= To: "pgsql-admin@lists.postgresql.org" Subject: Where to change the column width in RelOptInfo data Thread-Topic: Where to change the column width in RelOptInfo data Thread-Index: AdQjthRrMG5s4a0QRJukDR7uXgUZww== Date: Wed, 25 Jul 2018 01:29:58 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [123.235.238.115] Content-Type: multipart/alternative; boundary="_000_f372513e8bd843d6a424f951ea14dfa9EX01highgocom_" MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 124.133.18.218 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_f372513e8bd843d6a424f951ea14dfa9EX01highgocom_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 SGksDQoNCkkgdXNlIGEgcG9zdGdyZXMgZXh0ZW5zaW9uIHBsdWdpbiBwZ19zdHJvbSB0byBnZW5l cmF0ZSB0aGUgcGxhbi4gSSBzZWxlY3Qgb25lIGNvbHVtbiChsGF2ZyhjX2FjY3RiYWwpobEgaW4g dGhlIFNRTCwgYW5kIHRoZSBnZW5lcmF0ZWQgcGxhbiBjaGFuZ2VzIHRvIHNlbGVjdCB0d28gY29s dW1uIKGwY19hY2N0YmFsLCBjX3Bob25lobEuDQoNCldoZW4gdGhlIHBsYW4gZXhlY3V0ZXMsIGl0 IG5lZWQgdGhlIHdpZHRoIHZhbHVlIG9mIHRoZSB0d28gY29sdW1uKGNfYWNjdGJhbCwgY19waG9u ZSkgYnV0IEkgZmluZCB0aGUgYXR0cl93aWR0aHMgZmllbGQgaW4gUmVsT3B0SW5mbyBkYXRhIG9u bHkgaGFzIHRoZSB3aWR0aCBvZiBhY2N0YmFsLiBUaGUgd2lkdGggb2YgY19waG9uZSBpcyAwLg0K DQpJIHVzZSB0aGUgZ2RiIHRvIGRlYnVnIHRoZSBmdW5jdGlvbiBzZXRfcmVsX3dpZHRoLCBpdCBv bmx5IHNldCB0aGUgdGhlIHdpZHRoIG9mIGNfYWNjdGJhbC4NCg0KQWNjb3JkaW5nIHRvIG15IHVu ZGVyc3RhbmRpbmcgb2YgdGhlIGNvZGUsIHRoZSBSZWxPcHRJbmZvIHZhbHVlIGlzIGZpbGxlZCBi ZWZvcmUgdGhlIGV4dGVuc2lvbiBhcHBlbmQgYSBuZXcgcGF0aCB0byB0aGUgUGxhbm5lckluZm8s IGFuZCBpdCB3aWxsIG5vdCBjaGFuZ2UgZXZlbiBpZiB0aGUgbmV3IHBsYW4gY2hhbmdlIHRoZSB0 YXJnZXRsaXN0IGxlbmd0aCBmcm9tIDEgdG8gMi4gSXMgaXQgY29ycmVjdD8NCg0KSWYgSSB3YW50 IHRvIGNoYW5nZSB0aGUgY29kZSB0byBhZGQgdGhlIHdpZHRoIG9mIGNfcGhvbmUgaW4gUmVsT3B0 SW5mby0+YXR0cl93aWR0aHMsIHdoaWNoIHBsYWNlIGlzIGdvb2QgZm9yIGNoYW5nZT8NCg0KDQo9 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09IFRoZSBDYXNlID09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NCnBvc3RncmVzPSMgc2V0IGVuYWJsZV9zZXFz Y2FuPW9mZjsNClNFVA0KcG9zdGdyZXM9IyBleHBsYWluIHNlbGVjdA0KICAgICAgICAgICAgICAg ICAgICAgICBjX2FjY3RiYWwNCiAgICAgICAgICAgICAgICBmcm9tDQogICAgICAgICAgICAgICAg ICAgICAgICBjdXN0b21lcg0KICAgICAgICAgICAgICAgIHdoZXJlDQogICAgICAgICAgICAgICAg ICAgICAgICBjX2FjY3RiYWwgPiAoDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNl bGVjdA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF2ZyhjX2FjY3Ri YWwpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20NCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBjdXN0b21lcg0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICB3aGVyZQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IGNfYWNjdGJhbCA+IDAuMDANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBhbmQgc3Vic3RyaW5nKGNfcGhvbmUgZnJvbSAxIGZvciAyKSBpbg0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCcxOCcpDQogICAgICAgICAgICAgICAg ICAgICAgICApOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg UVVFUlkgUExBTg0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0N ClNlcSBTY2FuIG9uIGN1c3RvbWVyICAoY29zdD0xMDAwMDAwNDA5MC42MC4uMTAwMDAwMDQxNjEu MzUgcm93cz02MzMgd2lkdGg9NykNCiAgIEZpbHRlcjogKGNfYWNjdGJhbCA+ICQwKQ0KICAgSW5p dFBsYW4gMSAocmV0dXJucyAkMCkNCiAgICAgLT4gIEFnZ3JlZ2F0ZSAgKGNvc3Q9NDA5MC41OS4u NDA5MC42MCByb3dzPTEgd2lkdGg9MzIpDQogICAgICAgICAgIC0+ICBDdXN0b20gU2NhbiAoR3B1 U2Nhbikgb24gY3VzdG9tZXIgY3VzdG9tZXJfMSAgKGNvc3Q9NDA5MC41Ni4uNDA5MC41NiByb3dz PTEwIHdpZHRoPTcpDQogICAgICAgICAgICAgICAgIEZpbHRlcjogKCJzdWJzdHJpbmciKChjX3Bo b25lKTo6dGV4dCwgMSwgMikgPSAnMTgnOjp0ZXh0KQ0KICAgICAgICAgICAgICAgICBHUFUgUHJv amVjdGlvbjogY19hY2N0YmFsLCBjX3Bob25lDQogICAgICAgICAgICAgICAgIEdQVSBGaWx0ZXI6 IChjX2FjY3RiYWwgPiAwLjAwKQ0KKDggcm93cykNCg0KcG9zdGdyZXM9Iw0K --_000_f372513e8bd843d6a424f951ea14dfa9EX01highgocom_ Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable

Hi,

 

I use a postgres extension plug= in pg_strom to generate the plan. I select one column =A1=B0avg(c_acctbal)= =A1=B1 in the SQL, and the generated plan changes to select two column =A1= =B0c_acctbal, c_phone=A1=B1.

 

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 func= tion set_rel_width, it only set the the width of c_acctbal.

 

According to my understanding o= f the code, the RelOptInfo value is filled before the extension append a ne= w path to the PlannerInfo, and it will not change even if the new plan chan= ge 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 goo= d for change?

 

 

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Th= e Case =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<= /span>

postgres=3D# set enable_seqscan= =3Doff;

SET

postgres=3D# explain select&nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;    

     &= nbsp;           &nbs= p;     c_acctbal

     &= nbsp;          from<= /o:p>

     &= nbsp;           &nbs= p;      customer

     &= nbsp;          where

     &= nbsp;           &nbs= p;      c_acctbal > (

     &= nbsp;            &nb= sp;            =  select

     &= nbsp;           &nbs= p;            &= nbsp;         avg(c_acctbal)

     &= nbsp;           &nbs= p;            &= nbsp; from

     &= nbsp;           &nbs= p;            &= nbsp;         customer

     &= nbsp;           &nbs= p;            &= nbsp; where

     &= nbsp;           &nbs= p;            &= nbsp;         c_acctbal > 0.00

     &= nbsp;           &nbs= p;            &= nbsp;         and substring(c_phone= from 1 for 2) in

     &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;     ('18')

     &= nbsp;           &nbs= p;      );

     &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;  QUERY PLAN         &n= bsp;            = ;             &= nbsp;          

-------------------------------= ----------------------------------------------------------------------=

Seq Scan on customer  (cos= t=3D10000004090.60..10000004161.35 rows=3D633 width=3D7)<= /p>

   Filter: (c_acctbal= > $0)

   InitPlan 1 (return= s $0)

     -> =  Aggregate  (cost=3D4090.59..4090.60 rows=3D1 width=3D32)

     &= nbsp;     ->  Custom Scan (GpuScan) on customer= customer_1  (cost=3D4090.56..4090.56 rows=3D10 width=3D7)<= /span>

     &= nbsp;           Filter: (= "substring"((c_phone)::text, 1, 2) =3D '18'::text)

     &= nbsp;           GPU Proje= ction: c_acctbal, c_phone

     &= nbsp;           GPU Filte= r: (c_acctbal > 0.00)

(8 rows)

 

postgres=3D#<= /p>

--_000_f372513e8bd843d6a424f951ea14dfa9EX01highgocom_--