Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4Aqw-0007TN-2a for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 19:47:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4Aqu-0002p0-TT for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 19:47:20 +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 1f4Aqu-0002oq-MD for pgsql-hackers@lists.postgresql.org; Thu, 05 Apr 2018 19:47:20 +0000 Received: from mail-qt0-f193.google.com ([209.85.216.193]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f4Aqq-0007HA-NU for pgsql-hackers@postgresql.org; Thu, 05 Apr 2018 19:47:20 +0000 Received: by mail-qt0-f193.google.com with SMTP id v11so28215290qtj.6 for ; Thu, 05 Apr 2018 12:47:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=3ZSE2tIg8YjVcIydZ3EPjUaCpXF//jU7VAJJnhc9Zmc=; b=iEKccP2kyieJpbmzstSZIgUqtIFWMHopObPVbxySXNO6JaDNve3a8J6Zydu7EARnkS 54bgk18hrygNAeMEHazrnCTqCb0IEmMYHvN9TptlDUBYLQqlo4Rt539LWJBnzxYzDZhd zw0AtssLY4Um2YU+Qi/RBlPJw7cgGJlAOkCKcOUVLpCeRcLCjgC6elCY5EfvumNdxsVz +ssNxCXl1KARpE7Dd51hsq/ZxOqQyni6CWXjHBAHTqAmiSTe0on+/h63UnA3cgQ+NTb+ 24/uxKuiRtd2mx9J30g4A7ZKu46lVKb7yXJ82oZKqXnF9AJ89RfxaXy1zkAJPwH4Ckt4 9Clw== X-Gm-Message-State: ALQs6tDkZFyktl5lQ8mnDr5HmBntn+V6wlQg5IzTfEuVsqJnt1VZTDce ymwDjQ1i9og3HX14gu6viB67MQ== X-Google-Smtp-Source: AIpwx49PLrey8uYuo2PHaqV1U7KNugs3cR+TSR+ZG/ELRyW8/P6bL+vG0YWdEPyFBDQaAPPLBSdrpg== X-Received: by 10.200.47.120 with SMTP id k53mr34967562qta.151.1522957634161; Thu, 05 Apr 2018 12:47:14 -0700 (PDT) Received: from localhost.localdomain (c-24-61-8-151.hsd1.ma.comcast.net. [24.61.8.151]) by smtp.gmail.com with ESMTPSA id m66sm6602276qkl.57.2018.04.05.12.47.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 12:47:13 -0700 (PDT) Reply-To: jesper.pedersen@redhat.com Subject: Re: [HACKERS] Runtime Partition Pruning To: David Rowley Cc: Amit Langote , Rajkumar Raghuwanshi , Beena Emerson , Alvaro Herrera , Robert Haas , amul sul , "pgsql-hackers@postgresql.org" , Dilip Kumar References: <31e27e19-eaf6-642f-8eb6-9cc7528fa57b@lab.ntt.co.jp> <2dbe3de6-ad07-655f-1278-356709cbf185@lab.ntt.co.jp> <95dec133-7654-ce27-a7af-c91b0e58ad27@redhat.com> <8658bbec-9afe-8246-c0ff-254768b1bbe7@lab.ntt.co.jp> From: Jesper Pedersen Organization: Red Hat Message-ID: <8770beb8-12d4-e625-0ac1-a9021371c642@redhat.com> Date: Thu, 5 Apr 2018 15:47:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi David, First of all: Solid patch set with good documentation. On 04/05/2018 09:41 AM, David Rowley wrote: > Seems mostly fair. I'm not a fan of using the term "unpruned" though. > I'll have a think. The "all" is meant in terms of what exists as > subnodes. > 'included_parts' / 'excluded_parts' probably isn't better... > subplan_indexes and parent_indexes seem like better names, I agree. > More clear. >> * Also in make_partition_pruneinfo() >> >> /* Initialize to -1 to indicate the rel was not found */ >> for (i = 0; i < root->simple_rel_array_size; i++) >> { >> allsubnodeindex[i] = -1; >> allsubpartindex[i] = -1; >> } >> >> Maybe, allocate the arrays above mentioned using palloc0 and don't do this >> initialization. Instead make the indexes that are stored in these start >> with 1 and consider 0 as invalid entries. > > 0 is a valid subplan index. It is possible to make this happen, but > I'd need to subtract 1 everywhere I used the map. That does not seem > very nice. Seems more likely to result in bugs where we might forget > to do the - 1. > > Did you want this because you'd rather have the palloc0() than the for > loop setting the array elements to -1? Or is there another reason? > I think that doing palloc0 would be confusing; -1 is more clear, especially since it is used with 'allpartindexes' which is a Bitmapset. Doing the variable renames as Amit suggests would be good. I ran some tests (v50_v20) (make check-world passes), w/ and w/o choose_custom_plan() being false, and seeing good performance results without running into issues. Maybe 0005 should be expanded in partition_prune.sql with the supported cases to make those more clear. Thanks ! Best regards, Jesper