Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvmhq-0005jL-JE for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Feb 2019 17:27:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gvmho-0002UT-Qv for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Feb 2019 17:27: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvmho-0002UM-JN for pgsql-hackers@lists.postgresql.org; Mon, 18 Feb 2019 17:27:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvmhm-000728-C1 for pgsql-hackers@postgresql.org; Mon, 18 Feb 2019 17:27:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x1IHRZvq030973; Mon, 18 Feb 2019 12:27:36 -0500 From: Tom Lane To: Amit Langote cc: David Rowley , "Imai, Yoshikazu" , Amit Langote , Alvaro Herrera , Pg Hackers Subject: Re: speeding up planning with partitions In-reply-to: References: <8ea8bbb1-31ff-a469-02a7-281c3eba4bea@lab.ntt.co.jp> <201902011001.4v25uw6w6kb5@alvherre.pgsql> <0F97FA9ABBDBE54F91744A9B37151A5127865E@g01jpexmbkw24> <5d00eb35-375d-0672-0626-96bdb86829d0@lab.ntt.co.jp> Comments: In-reply-to Amit Langote message dated "Tue, 12 Feb 2019 15:41:15 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30971.1550510855.1@sss.pgh.pa.us> Date: Mon, 18 Feb 2019 12:27:35 -0500 Message-ID: <30972.1550510855@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > [ v22 patch set ] I started to look at this, and immediately choked on the 0001 patch: if (childpruned || !apply_child_basequals(root, rel, childrel, childRTE, appinfo) || relation_excluded_by_constraints(root, childrel, childRTE)) { Frankly, that code is just horrid. Having a function with side effects in an if-test is questionable at the best of times, and having it be the second of three conditions (which the third condition silently depends on) is unreadable and unmaintainable. I think the existing code here is considerably cleaner than what this patch proposes. I suppose you are doing this because you intend to jam some additional cleanup code into the successfully-pruned-it code path, but if said code is really too bulky to have multiple copies of, couldn't you put it into a subroutine? You're not going to be able to get to only one copy of such cleanup anyhow, because there is another early-exit further down, for the case where set_rel_size detects dummy-ness. regards, tom lane