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 1eonEJ-0006j0-EK for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Feb 2018 09:31:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eonEI-00028l-If for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Feb 2018 09:31:54 +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 1eonEI-00028b-8f for pgsql-hackers@lists.postgresql.org; Thu, 22 Feb 2018 09:31:54 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eonEE-00034c-AL for pgsql-hackers@postgresql.org; Thu, 22 Feb 2018 09:31:53 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w1M9VfeO014953; Thu, 22 Feb 2018 18:31:41 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 5735AEA82F0; Thu, 22 Feb 2018 18:31:41 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 42D51EA80FA; Thu, 22 Feb 2018 18:31:41 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 3CAB1400284; Thu, 22 Feb 2018 18:31:41 +0900 (JST) From: Amit Langote Subject: Re: [HACKERS] Runtime Partition Pruning References: <20180104163708.bzgheqsny6tsatzf@alvherre.pgsql> Message-ID: <31e27e19-eaf6-642f-8eb6-9cc7528fa57b@lab.ntt.co.jp> Date: Thu, 22 Feb 2018 18:31:23 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-CC-Mail-RelayStamp: 1 To: David Rowley , Rajkumar Raghuwanshi Cc: Beena Emerson , Alvaro Herrera , Robert Haas , amul sul , "pgsql-hackers@postgresql.org" , Dilip Kumar X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi David. On 2018/02/21 18:06, David Rowley wrote: > Other things I don't particularly like about the current patch are how > I had to construct the partition key expressions in > set_valid_runtime_subplans_recurse(). This pretty much uses code > borrowed from set_baserel_partition_key_exprs(). One way around that > would be to change the partprune.c code to deal with the > partkey->partattrs and consume an expression from the list on attnum = > 0. I didn't do that as I want to minimise how much I touch Amit's > patch before it gets committed as doing so would likely just cause > more headaches for me keeping this merged with his work. Another > option to resolve this would be to put the partition key expressions > into the PartitionPruneInfo. Another way could be to refactor the code you've borrowed from set_baserel_partition_key_exprs() into its own function that is exported by some optimizer header. I removed PartitionKey/Relation from signatures of various functions of my patch to avoid having to re-heap_open() the relation per [1]. > I've attached v11 of the patch. Some comments: * I noticed that the patch adds a function to bitmapset.c which you might want to extract into its own patch, like your patch to add bms_add_range() that got committed as 84940644d [2]. * Maybe it's better to add `default: break;` in the two switch's you've added in partkey_datum_from_expr() partprune.c: In function ‘partkey_datum_from_expr’: partprune.c:1555:2: warning: enumeration value ‘T_Invalid’ not handled in switch [-Wswitch] switch (nodeTag(expr)) partprune.c:1562:4: warning: enumeration value ‘PARAM_SUBLINK’ not handled in switch [-Wswitch] switch (((Param *) expr)->paramkind) * I see that you moved PartitionClauseInfo's definition from partprune.c to partition.h. Isn't it better to move it to partprune.h? Thanks, Amit [1] https://www.postgresql.org/message-id/CA%2BTgmoabi-29Vs8H0xkjtYB%3DcU%2BGVCrNwPz7okpa3KsoLmdEUQ%40mail.gmail.com [2] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=84940644d