From: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
To: pgsql-hackers@postgresql.org
Subject: Re: Minor code improvements to create_foreignscan_plan/ExecInitForeignScan
Date: Wed, 9 Sep 2015 19:08:30 +0900
Message-ID: <55F0051E.1020505@lab.ntt.co.jp> (raw)
In-Reply-To: <559F9323.4080403@lab.ntt.co.jp>
References: <559F9323.4080403@lab.ntt.co.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 2015/07/10 18:40, Etsuro Fujita wrote:
> To save cycles, I modified create_foreignscan_plan so that it detects
> whether any system columns are requested if scanning a base relation.
> Also, I revised other code there a little bit.
Attached is an updated version of the patch. The previous version
contained changes to ExecInitForeignScan, but I've dropped that part, as
discussed before.
Best regards,
Etsuro Fujita
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:create-foreignscan-plan.patch (text/x-patch, 2.9K) download
*** a/src/backend/optimizer/plan/createplan.c
--- b/src/backend/optimizer/plan/createplan.c
***************
*** 2058,2066 **** create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path,
RelOptInfo *rel = best_path->path.parent;
Index scan_relid = rel->relid;
Oid rel_oid = InvalidOid;
- Bitmapset *attrs_used = NULL;- ListCell *lc;- int i;
Assert(rel->fdwroutine != NULL);
--- 2058,2063 ----
***************
*** 2120,2155 **** create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path,
}
/*
! * Detect whether any system columns are requested from rel. This is a
! * bit of a kluge and might go away someday, so we intentionally leave it
! * out of the API presented to FDWs.
! *
! * First, examine all the attributes needed for joins or final output.
! * Note: we must look at reltargetlist, not the attr_needed data, because
! * attr_needed isn't computed for inheritance child rels.
*/
! pull_varattnos((Node *) rel->reltargetlist, rel->relid, &attrs_used);
!
! /* Add all the attributes used by restriction clauses. */
! foreach(lc, rel->baserestrictinfo)
{
! RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
! pull_varattnos((Node *) rinfo->clause, rel->relid, &attrs_used);
! }
! /* Now, are any system columns requested from rel? */
! scan_plan->fsSystemCol = false;
! for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
! {
! if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber, attrs_used))
{
! scan_plan->fsSystemCol = true;
! break;
}
- }
! bms_free(attrs_used);
return scan_plan;
}
--- 2117,2161 ----
}
/*
! * If we're scanning a base relation, detect whether any system columns
! * are requested from the rel. (Irrelevant if scanning a join relation.)
! * This is a bit of a kluge and might go away someday, so we intentionally
! * leave it out of the API presented to FDWs.
*/
! scan_plan->fsSystemCol = false;
! if (scan_relid > 0)
{
! Bitmapset *attrs_used = NULL;
! ListCell *lc;
! int i;
! /*
! * First, examine all the attributes needed for joins or final output.
! * Note: we must look at reltargetlist, not the attr_needed data,
! * because attr_needed isn't computed for inheritance child rels.
! */
! pull_varattnos((Node *) rel->reltargetlist, scan_relid, &attrs_used);
! /* Add all the attributes used by restriction clauses. */
! foreach(lc, rel->baserestrictinfo)
{
! RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
!
! pull_varattnos((Node *) rinfo->clause, scan_relid, &attrs_used);
}
! /* Now, are any system columns requested from rel? */
! for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
! {
! if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber, attrs_used))
! {
! scan_plan->fsSystemCol = true;
! break;
! }
! }
!
! bms_free(attrs_used);
! }
return scan_plan;
}
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: fujita.etsuro@lab.ntt.co.jp
Subject: Re: Minor code improvements to create_foreignscan_plan/ExecInitForeignScan
In-Reply-To: <55F0051E.1020505@lab.ntt.co.jp>
References: <559F9323.4080403@lab.ntt.co.jp> <55F0051E.1020505@lab.ntt.co.jp>
* 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