Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZVGn7-0001V5-61 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2015 10:21:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZVGn6-0006Rk-H5 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2015 10:21:48 +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.84) (envelope-from ) id 1ZVGn5-0006Qs-27 for pgsql-hackers@postgresql.org; Fri, 28 Aug 2015 10:21:47 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZVGn0-0001yF-Nv for pgsql-hackers@postgresql.org; Fri, 28 Aug 2015 10:21:45 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id t7SALSKw000781; Fri, 28 Aug 2015 19:21:28 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id B46515F594; Fri, 28 Aug 2015 19:21:28 +0900 (JST) Received: from imail3.m.ecl.ntt.co.jp (imail3.m.ecl.ntt.co.jp [129.60.5.248]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id A64BD5F592; Fri, 28 Aug 2015 19:21:28 +0900 (JST) Received: from [129.60.241.75] ([129.60.241.75]) by imail3.m.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id t7SALSq0003367; Fri, 28 Aug 2015 19:21:28 +0900 Message-ID: <55E035F9.1030008@lab.ntt.co.jp> Date: Fri, 28 Aug 2015 19:20:41 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: David Rowley CC: PostgreSQL-development Subject: Re: Minor code improvements to create_foreignscan_plan/ExecInitForeignScan References: <559F9323.4080403@lab.ntt.co.jp> <55AF3748.9080901@lab.ntt.co.jp> In-Reply-To: <55AF3748.9080901@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Pg-Spam-Score: -4.0 (----) 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 On 2015/07/22 15:25, Etsuro Fujita wrote: > On 2015/07/10 21:59, David Rowley wrote: >> On 10 July 2015 at 21: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. >> I just glanced at this and noticed that the method for determining if >> there's any system columns could be made a bit nicer. >> /* 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; >> } >> } >> I think could just be written as: >> /* Now, are any system columns requested from rel? */ >> if (!bms_is_empty(attrs_used) && >> bms_next_member(attrs_used, -1) < -FirstLowInvalidHeapAttributeNumber) >> scan_plan->fsSystemCol = true; >> else >> scan_plan->fsSystemCol = false; >> I know you didn't change this, but just thought I'd mention it while >> there's an opportunity to fix it. On second thought, I noticed that there is a case when that fix doesn't work well; bms_next_member wouldn't be efficient when only the rear user-columns are requested from a foreign table that has a large number of user-columns. So, I'm inclined to leave that as-is. Anyway, I'll add this to the upcoming CF. 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-hackers