Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTIeY-00075u-BE for pgsql-admin@arkaria.postgresql.org; Tue, 28 Apr 2020 05:19:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jTIeX-0003mf-9h for pgsql-admin@arkaria.postgresql.org; Tue, 28 Apr 2020 05:19:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTIeW-0003mS-Uy for pgsql-admin@lists.postgresql.org; Tue, 28 Apr 2020 05:19:29 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jTIeP-0004uy-S7 for pgsql-admin@postgresql.org; Tue, 28 Apr 2020 05:19:28 +0000 Received: by mail-wm1-x331.google.com with SMTP id z6so1326402wml.2 for ; Mon, 27 Apr 2020 22:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=XcQQviAbYvXQtPGiuyGmxq/OZY7UtgkOtYzBpx1s1Ms=; b=wBPk80ARY4ZsWb6mt12PAjgUtUQtIGECfxJV7N9yWCWUBU/lM2Uuinhq/gsbC5CopP zdGiFHg1i6jpeNHjiuX02Z0XTmGRfdJ+fEyjZGyysmRRGKOpIzUuPDyb/ZY/oY4UPHGH 1RDuHwAwXVuatk2c2SDc9kBXOzGEGuoVIEQzrUqbfVvSyPzjXYqzwMXQimavHE1b3ZZW EPiLIAb2teK5TGC1Pj1qL7fIlk/xYPMdW7VG8taEBIBbJUDVMmEcpDtajVFiwjfgsY+C q865V5VPyf2Mi3ZMHw19jJi2fPuOvLm+5dQyxYIR7rb2W/dlFSiVyl6yfoX7dwAe/K// gIOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=XcQQviAbYvXQtPGiuyGmxq/OZY7UtgkOtYzBpx1s1Ms=; b=LV8aQjyYtkeQpzqj0pKY0dXUkSn3w/Cz0c7W2miIkkdqeTpOu8t6jYNaLKrENvaGAh xTDnTqw8r7PRHqgrSWXitz2cXsCFYgY+SVOVJyWEp+BiRc+of9+n6Xuxaqbau+vjbzV8 9fVQbyWY9DFSJBNEyT6rhALJhcJYg2sc4hIAX3JgZPXlLBZ74AFEAoFBy1Rjo9hPdKe7 0T1OY6zs4LYdTsaAyekyWzABZ7ageMWct5Pgc3Uvbbn2KiEllsz7xQHfQvvF5XYQehkx CuHxetBycwLuoIEQT9mei6B95yDumf2Uu70abwmM7M/9oK1//zWm09LYm0CfRO5rM8tU 1b3w== X-Gm-Message-State: AGi0PuYVFjSB8FTCBCHuIgnn+9qsYX13EHtV3jgodf9GePHp+Ens4TdB 22nFCIThK4WxfuJ379N/jJy5uw== X-Google-Smtp-Source: APiQypJnEVMkt+ljhcZMNwC6dyzqhQntI/SBc+P4qfV2CxZl5stQ72hNcH+r3NXz1plefvZwWLAbUg== X-Received: by 2002:a1c:5642:: with SMTP id k63mr2408569wmb.188.1588051160058; Mon, 27 Apr 2020 22:19:20 -0700 (PDT) Received: from dynamic-eoszt3j6a3fsuo2k0-pd01.res.v6.highway.a1.net (dynamic-eoszt3j6a3fsuo2k0-pd01.res.v6.highway.a1.net. [2001:871:60:b39d:50a4:2496:3e1a:a0f0]) by smtp.gmail.com with ESMTPSA id b66sm1791136wmh.12.2020.04.27.22.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 22:19:19 -0700 (PDT) Message-ID: <2d96b24babb2170916a3556e0a4be5bf620aa6da.camel@cybertec.at> Subject: Re: Partitions and planner From: Laurenz Albe To: J T , "[ADMIN]" Date: Tue, 28 Apr 2020 07:19:16 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2020-04-27 at 16:03 -0700, J T wrote: > This is an odd question. I hope there is a workaround or feature for this that can use. > > We have a huge table close to a billion rows that we are testing a partition by by hash and sub partitions > by date range so we can drop the old partitions. > > The hash partition we want for performance but the dat range partition just for maintenance. Having said that. > On our non partitioned table the execution time is fine and the planning time is down to 4ms. > However, on the partitioned table the execution time is fast but the planning time jumps to 300ms. > A change of just a few milliseconds is impactful. But, a change of a few hundred milliseconds is not acceptable. > > Having said all this, is there a way to tell the planner not to plan using the sub partitions and only > use the primary hash partition? This way we could eliminate the extra planning time used on the sub partitions > since those sub partitions will ever only be used for pruning data. The planner *has* to consider the subpartitions, because that's where the actual data is. It seems like you have too many partitions for the PostgreSQL version you are using. Consider upgrading to v12, and consider doing away with hash partitioning. Do you have any evidence that it improves performance in your case? Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com