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 1gGsyN-0001As-25 for pgsql-performance@arkaria.postgresql.org; Sun, 28 Oct 2018 21:51:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gGswE-0005PF-2T for pgsql-performance@arkaria.postgresql.org; Sun, 28 Oct 2018 21:49:38 +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 1gGswD-0005P7-Me for pgsql-performance@lists.postgresql.org; Sun, 28 Oct 2018 21:49:37 +0000 Received: from mail-it1-x141.google.com ([2607:f8b0:4864:20::141]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gGsw5-0002dz-TK for pgsql-performance@postgresql.org; Sun, 28 Oct 2018 21:49:37 +0000 Received: by mail-it1-x141.google.com with SMTP id d6so1689766itl.4 for ; Sun, 28 Oct 2018 14:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=vzLyPzIY/VWM88h7D+7K3muQdPjibyDbSsiOSgtyPX8=; b=haKI5U90OLEHZcdDgUNMgj04hzvQULmlGH+lxlKy+/w6sU4iel69Q5Kuy6CeTF6BOA Ch+ilVKBV9U2LuSbdTeg70khiZ49FT/GSABQwHP2xmphXkSVXpxnAcXGB3T8Zq27I9Oh oOZAJMwEWPUHpn+VD55flj7JfCQQC1OltzfphjvhcN26C+hnh4mhWFMhFesKTe7QyuxV JC8lElkfVY3Hk1RTByihZyC1yOzHvFfmMLUgZqQmUZVOW16NWSsChm5VyGnZjMzS2djf +5F8TehnN2s/wyleT4HczSuo7kpB6OSmltUcLoJDy1WclrDxvp5R1d5WEZVMGIJe9S+Y berQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=vzLyPzIY/VWM88h7D+7K3muQdPjibyDbSsiOSgtyPX8=; b=GVLDAdz/lsToQ8gBiexorrqMTTlakk0Ua/O23lcsNNSMuDEWfZZuscuLKuc2PKJfPc l+gtzNeZ5ScypYBVgiz5N9N5fD0xNC9ozviTfwI3m74UUBbf2obL7hyI2WmniKZ2j04I PewrWNBjWNuyxFlpD+UsymzBu1VGeSvS1v5kMaPn66OmNbWuaiqNkGutHxsPawH/fhNE ki9QBx2QWfOagmpek+HKp6+cbXrrshvqnrRWZkXu3hOrxq4BZyiEkDnETE9xtfGjRFyu eSQ6/uqZl4or9uv3wq8Zjn49mB8dkO99s4Hd0aNsiL/onfR7KOG3NVKWTFumBU2JUI9Y azWQ== X-Gm-Message-State: AGRZ1gI7VWVVUe6/+s0y1Tuhh9yuiTiFdMtgKn+qo0sxOnMnCY7OrvK1 z+NjtATak0yw8XgkYNZWSFpzH7RVHFAahw== X-Google-Smtp-Source: AJdET5ci/Hvp1jIw7qkBCN0p2TBXp8dUGwMsXhQO1jE/0yBLy9cChssb11GLZsqoPZi3+WrWL9IFgA== X-Received: by 2002:a24:7556:: with SMTP id y83-v6mr1094687itc.4.1540763367457; Sun, 28 Oct 2018 14:49:27 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id i17-v6sm6427665iog.56.2018.10.28.14.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 14:49:26 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id A5DD7804FC9; Sun, 28 Oct 2018 16:49:24 -0500 (CDT) Date: Sun, 28 Oct 2018 16:49:24 -0500 From: Justin Pryzby To: Dave E Martin Cc: pgsql-performance@postgresql.org Subject: Re: DELETE / UPDATE from partition not optimized (11.0) Message-ID: <20181028214924.GA26843@telsasoft.com> References: <20181026154540.GA27004@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181026154540.GA27004@telsasoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Oct 26, 2018 at 10:45:40AM -0500, Justin Pryzby wrote: > On Thu, Oct 25, 2018 at 10:43:10AM -0600, Dave E Martin wrote: > > If SELECT is confident enough to limit itself to one partition, why isn't > > DELETE (or UPDATE)? > > Because of this limitation: > > https://www.postgresql.org/docs/current/static/ddl-partitioning.html#DDL-PARTITION-PRUNING > |Currently, pruning of partitions during the planning of an UPDATE or DELETE > |command is implemented using the constraint exclusion method (however, it is > |controlled by the enable_partition_pruning rather than constraint_exclusion) — > |see the following section for details and caveats that apply. I meant to add that one can use a redundant constraints in addition to the partition bounds, both specifying the same condition. That also allows detaching and re-attaching the partition without a table scan (which is why we do it). Justin