Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxyo5-0000T7-5o for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2017 16:38:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cxyo4-0006Hs-Nt for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2017 16:38:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cxyma-0003XU-RM for pgsql-hackers@postgresql.org; Tue, 11 Apr 2017 16:36:45 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxymX-0006bW-C7 for pgsql-hackers@postgresql.org; Tue, 11 Apr 2017 16:36:43 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 040C021C26F0 for ; Tue, 11 Apr 2017 19:36:38 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru From: Dmitry Ivanov To: pgsql-hackers Subject: Possible problem in Custom Scan API Date: Tue, 11 Apr 2017 19:36:11 +0300 MIME-Version: 1.0 Message-ID: Organization: Postgres Professional User-Agent: Trojita/0.7; Qt/5.8.0; xcb; Linux; Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi hackers, I'm struggling to understand one particular thing about Custom Scan API. As you may know, there's a function called use_physical_tlist(), which aims= =20 to eliminate meaningless projections during query execution. Any scan node= =20 (e.g. CustomScan) aims to take advantage of physical targetlists... except= =20 for the IndexOnlyScan (for obvious reasons): createplan.c, create_scan_plan(): if (use_physical_tlist(root, best_path, flags)) { if (best_path->pathtype =3D=3D T_IndexOnlyScan) { /* For index-only scan, the preferred tlist is the index's */ tlist =3D copyObject(((IndexPath *) best_path)->indexinfo->indextlist); ... } ... } In theory, CustomScans should be able to use any Plan nodes (i.e.=20 'custom_plans' list), but as far as I can understand, there's no way to=20 override behavior of use_physical_tlist(), which means that we might see=20 something like this: ERROR: variable not found in subplan target list if we use child IndexOnlyScan and the index does not include some of the=20 relation's columns. Is there any existing workaround? --=20 Dmitry Ivanov Postgres Professional: http://www.postgrespro.com Russian Postgres Company --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers