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 1hvvHs-0001FU-W1 for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2019 03:09:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hvvHq-0004Tn-Qz for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2019 03:09:50 +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 1hvvHq-0004Pb-Dz for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2019 03:09:50 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hvvHi-0000BI-Pm for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2019 03:09:50 +0000 Received: by mail-pl1-x641.google.com with SMTP id b3so44419603plr.4 for ; Thu, 08 Aug 2019 20:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=jdGEtQ7B8UEt5hTWRTUK21tthJoVojMaQaSmDhPMCBc=; b=ogmsuLjqwHbe7h23cxDdnuK9YQCLnWj0FIxK0vgkSTVZU1ell1BPdYNIzCveVKFBvT WD8BPiIX5HJ/8gsHpcB5Rq/swjx835G/Wd+lCKAk9RJPLECYAfus9S1HwyirKITDa3EH tRVBHMmP43AlQdO5UB75XrzkRNsJWYm4Bmz6s8dcxy8q8utoUuhL5mLziiFHyu3QXTsN xqmqDm8z6jnUwhSZ1VXBXMzw91U3/NRdgyU6HA4A5xVgjyy+EP5gsDWpZiMMnyeTVsEA TxyrMAxGmM5n7g9vAnfP76kkPMb+nUr3SDOy8dzfOcmqOB2awJ+ELQ6qbt1oiGpDkIka cXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=jdGEtQ7B8UEt5hTWRTUK21tthJoVojMaQaSmDhPMCBc=; b=Racl187fxjK2pLoxUzUVq/l/K6sdJdBPKt0ZvLXjJiRyWRQ4GIHAcCcdx0axioK7C4 F9sVgFQTPB8zf8x4WCoKmDGy44d+7uOOVdBTfI+zHKpcA2DWHdPaGTSKZ9Ct6+s+73P7 tNXywcUWR7Sg/D59Sdh0CjBhktSWMVhUEx8MTDZLgVjBzTesvRT9M/2zG1dLy/oPah0y LPLn5eCQYVxpKZE28YsAikEOWeil3JkCa3YW4xnXISEleUC09b0LgK34sUjEExvgkSeo 3V9Fhs2NZqxxEEJj+/PPRXCjkN2X1CXxiqIKsfQUHiD7AhAvlaZm1cvQiLJOnQnESyLA /EtQ== X-Gm-Message-State: APjAAAX4nxm0pTMQFVRMRy+jnd0pGLpnLjk/xihgf4SEeteLDr7OLoZ0 w/iRjM+FaywTGPD6aAiOYynNIWR8 X-Google-Smtp-Source: APXvYqxpQYhuzAHyAIfUuaZ+H5nRfrFQRST3GrABzHXIvjiRUiQif+wcGZ2msiq/PVeB/GjW1Syi1A== X-Received: by 2002:a17:902:24b:: with SMTP id 69mr16159966plc.250.1565320179894; Thu, 08 Aug 2019 20:09:39 -0700 (PDT) Received: from localhost (w204177.dynamic.ppp.asahi-net.or.jp. [121.1.204.177]) by smtp.gmail.com with ESMTPSA id h11sm10029585pgv.5.2019.08.08.20.09.36 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Aug 2019 20:09:39 -0700 (PDT) Date: Fri, 09 Aug 2019 12:09:20 +0900 (Tokyo Standard Time) Message-Id: <20190809.120920.64991939.horikyota.ntt@gmail.com> To: amitlangote09@gmail.com Cc: alvherre@2ndquadrant.com, simon@2ndquadrant.com, yuzukohosoya@gmail.com, shawn.wang.pg@gmail.com, shawn.wang@highgo.ca, pgsql-hackers@lists.postgresql.org Subject: Re: Problem with default partition pruning From: Kyotaro Horiguchi In-Reply-To: References: <20190807202706.GA14015@alvherre.pgsql> User-Agent: Mew version 6.5 on Emacs 22.2 / Mule 5.0 =?iso-2022-jp?B?KBskQjpnGyhCKQ==?= / Meadow-3.01-dev (TSUBO-SUMIRE) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Sorry for being late. I found it is committed before I caught up this thread again.. At Thu, 8 Aug 2019 14:50:54 +0900, Amit Langote wrote in > Hi Alvaro, > > On Thu, Aug 8, 2019 at 5:27 AM Alvaro Herrera wrote: > > On 2019-Aug-07, Simon Riggs wrote: > > > I saw your recent commit and it scares me in various places, noted below. > > > > > > "Commit: Apply constraint exclusion more generally in partitioning" > > > > > > "This applies particularly to the default partition..." > > > > > > My understanding of the thread was the complaint was about removing the > > > default partition. I would prefer to see code executed just for that case, > > > so that people who do not define a default partition are unaffected. > > > > Well, as the commit message noted, it applies to other cases also, not > > just the default partition. The default partition just happens to be > > the most visible case. > > Just to be clear, I don't think there was any patch posted on this > thread that was to address *non-default* partitions failing to be > pruned by "partition pruning". If that had been the problem, we'd be > fixing the bugs of the partition pruning code, not apply constraint > exclusion more generally to paper over such bugs. I may be misreading > what you wrote here though. > > The way I interpret the "generally" in the "apply constraint exclusion > more generally" is thus: we can't prune the default partition without > the constraint exclusion clutches for evidently a broader sets of > clauses than the previous design assumed. The previous design assumed > that only OR clauses whose arguments contradicted the parent's > partition constraint are problematic, but evidently any clause set > that contradicts the partition constraint is problematic. Again, the > problem is that it's impossible to prune the "default" partition with > such clauses, not the *non-default* ones -- values extracted from > contradictory clauses would not match any of the bounds so all > non-default partitions would be pruned that way. > > By the way, looking closer at the patch committed today, I realized I > had misunderstood what you proposed as the *4th* possible place to > move the constraint exclusion check to. I had misread the proposal > and thought you meant to move it outside the outermost loop of > gen_partprune_steps_internal(), but that's not where the check is now. > I think it's better to call predicate_refuted_by() only once by > passing the whole list of clauses instead of for each clause > separately. The result would be the same but the former would be more > efficient, because it avoids repeatedly paying the cost of setting up > predtest.c data structures when predicate_refuted_by() is called. > Sorry that I'm only saying this now. +1 as I mentioned in [1]. > Also it wouldn't be incorrect to do the check only if the parent has a > default partition. That will also address the Simon's concern this > might slow down the cases where this effort is useless. > > I've attached a patch that does that. When working on it, I realized > that the way RelOptInfo.partition_qual is processed is a bit > duplicative, so I created a separate patch to make that a bit more > consistent. 0001 seems reasonable. By the way, the patch doesn't touch get_relation_constraints(), but I suppose it can use the modified partition constraint qual already stored in rel->partition_qual in set_relation_partition_info. And we could move constifying to set_rlation_partition_info? Also, I'd like to see comments that the partition_quals is already varnode-fixed. And 0002, yeah, just +1 from me. [1] https://www.postgresql.org/message-id/20190409.173725.31175835.horiguchi.kyotaro@lab.ntt.co.jp regards. -- Kyotaro Horiguchi NTT Open Source Software Center