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 1lLqd4-0000Jl-FL for pgsql-performance@arkaria.postgresql.org; Mon, 15 Mar 2021 17:03:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLqd3-0004MQ-3V for pgsql-performance@arkaria.postgresql.org; Mon, 15 Mar 2021 17:03:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLqd2-0004MJ-P0 for pgsql-performance@lists.postgresql.org; Mon, 15 Mar 2021 17:03:40 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lLqcz-0000aG-PC for pgsql-performance@postgresql.org; Mon, 15 Mar 2021 17:03:39 +0000 Received: by mail-io1-xd2c.google.com with SMTP id z13so34139793iox.8 for ; Mon, 15 Mar 2021 10:03:37 -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:in-reply-to:user-agent; bh=K5szZS8ihgv9b3NkD/iFMLj6LwkOZo7aR0NsYbO/g2k=; b=h4Y3WlTmfUYmjORhAYZhQ3+irPOJlxG4aN7WMeP2jZKr5Or4T3caMUGmR8PCJvmj8W I5X6lezjsn0izj58N7U7/9VJPtMIuZ2RYEn+jCYRhDSyaYHJDLd791HY7p0yKBcfg/bj De0C6cvzN7TA/KSyCiAuKlYIBl8WGgTaTRpWZPWZoRMXdV4iXDdJd4VrKSzTZFZ9nIRE SplCjX4eh31advxuDteDZXKfIyWgbblURuMBrlt8GSfszzksb151lbapOKLWMfH07apH m6FylJwcO9QccwYxuYZ9BWj7EHtftuWpZqK5GwilL9h8QLxMh9VhkAKQxeGsSurLeHGF xeVg== 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:in-reply-to:user-agent; bh=K5szZS8ihgv9b3NkD/iFMLj6LwkOZo7aR0NsYbO/g2k=; b=FBZI/c1rXZMXhjtSwQcS7WohBo6kAgWIRp/q3D1C1PH2FTgO/GO8K4SnHTLRATmvei +GpJLm/Up4anzUtyuCwt1TocdWayx62QawThZi4mSiga1RAB5MJFmyKfzBjxXnNsjCOl CSTHev2cs4EMvoUUInmMIXBaj7VGDxyk2B/lPMs4hM8YmS7HbuoYFllbIKEatSSeeGER God/9jUsuG/sl5Kuu/RLNZ04UpnX/XPKXcRjviDy5Z1vZ7zV9wOi8mSahhK3TnpTSxRA uudz5qXTRTXSgVWHKIIf53h2fyQwBA2j9DaiDJpA5uCZfwe4M7Uosa/AGryiu/jH4eH/ 9Icw== X-Gm-Message-State: AOAM530mu+DMf3pVAZev3whr+ceDgQwuDYkSrMetylNbk3dcsqG+/mbP /It9Gke6qG0S6x6vRZiOWdQ2RYebfrmENw== X-Google-Smtp-Source: ABdhPJyfkLPh+Q+oQrbDmL94ZfJhKSMz/oB3fBfDLrUS5kWiiwEYmgS6NdePXuxDvtU8Y8LbMzPF/g== X-Received: by 2002:a6b:ed08:: with SMTP id n8mr364817iog.197.1615827816556; Mon, 15 Mar 2021 10:03:36 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z12sm6803274ilb.18.2021.03.15.10.03.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 10:03:36 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 25BBF80083D; Mon, 15 Mar 2021 12:03:35 -0500 (CDT) Date: Mon, 15 Mar 2021 12:03:35 -0500 From: Justin Pryzby To: S Bob Cc: pgsql-performance@postgresql.org Subject: Re: wide table, many many partitions, poor query performance Message-ID: <20210315170334.GR29463@telsasoft.com> References: <6fc233c8-eba9-b042-5578-525270724bec@quadratum-braccas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fc233c8-eba9-b042-5578-525270724bec@quadratum-braccas.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 15, 2021 at 10:53:06AM -0600, S Bob wrote: > We have a client that is running PostgreSQL 12, they have a table with 212 > columns and 723 partitions > > It seems the planning time is consumed by generating 723 sub plans Is plannning time the issue ? Please show diagnostic output. You can start from here: https://wiki.postgresql.org/wiki/Slow_Query_Questions > I suspect it's due to the fact that they are using hash based partitioning, > example: > > CREATE TABLE rental_transaction_hash_p723 PARTITION OF rental_transaction > FOR VALUES WITH (MODULUS 723, REMAINDER 723); > > Based on a strategy like this, queries will ALWAYS scan all partitions > unless a hash value is specified as part of the query, correct? I suspect > this is the issue... looking for confirmation, or feedback if i'm off base You didn't say anything about the query, so: yes, maybe. The partition strategy and key need to be selected to optimize the intended queries. Hash partitioning is frequently a mistake. See also: https://www.postgresql.org/message-id/20200502140032.GI28974@telsasoft.com https://www.postgresql.org/message-id/20200602173353.GB30144@telsasoft.com -- Justin