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 1huAhC-0002Zq-2q for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Aug 2019 07:12:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1huAhA-0006no-P8 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Aug 2019 07:12:44 +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 1huAhA-0006nh-GX for pgsql-hackers@lists.postgresql.org; Sun, 04 Aug 2019 07:12:44 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huAh7-00067h-E1 for pgsql-hackers@lists.postgresql.org; Sun, 04 Aug 2019 07:12:43 +0000 Received: by mail-qt1-x843.google.com with SMTP id r6so73868767qtt.0 for ; Sun, 04 Aug 2019 00:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=J9+vA0tYk+OUgLc7TQxh0h+3mxI7eQbsMlw81vVSuCs=; b=AQu4enyaXyEiauVOQAYgG1Y6f0mTWyMnfRNs8IW5WIoDaj2Y9EZWvUubhfM1Tr1GfS Gt69EijKzgRYOGGSdmtEMazZZA9H3+16Z8zWIytVVESRZVBwajCvcznOPhpX6oYjR3N4 Wo92L+g4ikr9o0RnSbiUZnzBkN9pxqN1zLE2QFoUlVtOMUdZgkDdM9u4RPJfizNjXOK3 8cjkS2oZOhQxeoEUyF4AkF1Cf41MT1xNnmawHUXtrzd4soOAXSddlrHWiSPtATEsu3Lu Zas2/ptLfIkS8OtIMjP0nkx1uCxdgw/d849m+voi6rbBqb0O364kQ9sLrUvxDnBNdYMF oE+w== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=J9+vA0tYk+OUgLc7TQxh0h+3mxI7eQbsMlw81vVSuCs=; b=oIlNqQrFHaCpWBHgA8NZYqDDI/ro0kS6vD5Zf0wKoNgkqTXURah2miHw4vrk1F6ceL ZnXAsl1vFGc302VWbzBNzPQVSpgk+ZI+eZfxAI1wWp01F0N0ApJS6WeWKQRBd+HZyqWS WKLwJjp+7yJKdriNWUPxzKgshzffesqStO4Ynq25STfHJQ3RmTjF4GDSwcKcCgnrPDqF FLJAY0jPJLf08WAf0ABW6s1or8rQI+KV9EPS3v8EyGRZ3O0NF9+EIqrMakTva+K+enmQ cEQrDR4oRJCOm9/DULNj0EEmmERiD1N0YkHnExQj5bRCFtmW7mAEuVz1a+eyu2XoTCcg uHtA== X-Gm-Message-State: APjAAAVX2Hhe/m4Q/WCmZ6ye7WE66QEJU6ifiQG6oeRa0wPcoWg8aAzH YCVOfIgQoD3DC9NMEjTFgHF9ZA== X-Google-Smtp-Source: APXvYqxIh7ePZCeTd+MyV1NilW6trNGrlMtVK0hS7Exj95lXP7J+r28vV78Mk1NUwddDGasknkjiLA== X-Received: by 2002:a0c:9163:: with SMTP id q90mr107152799qvq.37.1564902757996; Sun, 04 Aug 2019 00:12:37 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.139.198]) by smtp.gmail.com with ESMTPSA id x8sm33121017qkl.27.2019.08.04.00.12.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 00:12:37 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 9B5D2120662; Sun, 4 Aug 2019 03:12:32 -0400 (-04) Date: Sun, 4 Aug 2019 03:12:32 -0400 From: Alvaro Herrera To: Amit Langote Cc: yuzuko , shawn wang , Shawn Wang , PostgreSQL Hackers Subject: Re: Problem with default partition pruning Message-ID: <20190804071232.GA7303@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190804062925.GA5861@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk So this is the best commit messages I could come up with at this stupid hour. I think the wording is pretty poor but at least it seems correct. I'm not sure I'll be able to get this pushed tomorrow, but I'll try. Improve pruning of a default partition When querying a partitioned table containing a default partition, we were wrongly deciding to include it in the scan too early in the process, failing to exclude it in some cases. If we reinterpret the PruneStepResult.scan_default flag slightly, we can do a better job at detecting that it can be excluded. The change is that we avoid setting the flag for that pruning step unless the step absolutely requires the default partition to be scanned (in contrast with the previous arrangement, which was to set it unless the step was able to prune it). So get_matching_partitions() must explicitly check the partition that each returned bound value corresponds to in order to determine whether the default one needs to be included, rather than relying on the flag from the final step result. Author: Yuzuko Hosoya Reviewed-by: Amit Langote Discussion: https://postgr.es/m/00e601d4ca86$932b8bc0$b982a340$@lab.ntt.co.jp -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services