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 1lLqdT-0000LQ-39 for pgsql-performance@arkaria.postgresql.org; Mon, 15 Mar 2021 17:04:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLqdS-0006Yv-0Q for pgsql-performance@arkaria.postgresql.org; Mon, 15 Mar 2021 17:04:06 +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 1lLqdR-0006Yo-Q7 for pgsql-performance@lists.postgresql.org; Mon, 15 Mar 2021 17:04:05 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lLqdO-0008K6-9Z for pgsql-performance@postgresql.org; Mon, 15 Mar 2021 17:04:05 +0000 Received: by mail-ej1-x630.google.com with SMTP id lr13so67547710ejb.8 for ; Mon, 15 Mar 2021 10:04:02 -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=Q0KTL8wLlBsBaGVNLyawrBtCmmrJhpwy/YqynlR00I4=; b=jouA43x+UJUhu4e+G3gNScUhXRebhkTOp7ML8LhKtE95EbK/ngvykj1bkb6/xhk5F9 c35EKXggf06CKcae7lCgFzfmo9Dy25s14AtVztMBA6EQyNB4Jmw0kRh9WGmEw2GRguxs dwfQLHVZM+jAeNuOUIRuSysxUC7tKQSEeTFFxOlxiDy3nnx3EQB9He9oL7YHDsKgcSt6 wr7F8nD87V/piUZM9K8BNvSxnLVQq1MJ1YBdYFMaiic0GChX8DFIOcSq7wzezLHQ/sIr K57tu2EdPckrBR/4bOo+mueWjpfqSma/mzYcpOXO8ltYabJpR4Rt3gIRVfpd0rMQl0kv c6aw== 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=Q0KTL8wLlBsBaGVNLyawrBtCmmrJhpwy/YqynlR00I4=; b=CNS8E0+u0Zi0poEEBEfpw8jd/Pr+N7I/gnA3ge+TuN3yLA/u98Iu7O45pTttIRyMpA QNhGo2nmpi/Acy1rdJhnWyK+gaZ4rRrcFQiRDYPxCAne/SnH7/nVoR2fiCtd56KC32N9 8/lKqPbBggmFFKiSto11jkuH6bRCDtEjle9M9idppea11zhmY9B3xBSvWDUOMJOkg3nh FfWmEfihxnFmjC1D7LC3a0qi7ycITctrMMnFjcebSSfL/lWrOHYz6rD3c4c5qizgT7kv APCi+NdMxUNXfrMsuAkR0Ks/CXSKyGArYlSE8NwPgpamy9WT97gj9tT4nBBxdHrAOpGn ibHQ== X-Gm-Message-State: AOAM531RdjZKG3pkSyix6rHzSgc1d8jQ7kD6WzqFWR5kf6Z0+bPt5xLH 8wPew0gYm6b1Ze7oqDGwebLOCQ== X-Google-Smtp-Source: ABdhPJxBoCfTONz4pGdf6gIoeQQS6K6YWcw5B6/cCrmg2iCYD3rMkrzwNz5/PUTxZQNgAW1gMIfuKg== X-Received: by 2002:a17:906:3881:: with SMTP id q1mr24951297ejd.490.1615827840733; Mon, 15 Mar 2021 10:04:00 -0700 (PDT) Received: from localhost.localdomain (217-149-171-45.nat.highway.telekom.at. [217.149.171.45]) by smtp.gmail.com with ESMTPSA id j25sm8628526edy.9.2021.03.15.10.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 10:04:00 -0700 (PDT) Message-ID: Subject: Re: wide table, many many partitions, poor query performance From: Laurenz Albe To: S Bob , pgsql-performance@postgresql.org Date: Mon, 15 Mar 2021 18:03:59 +0100 In-Reply-To: <6fc233c8-eba9-b042-5578-525270724bec@quadratum-braccas.com> References: <6fc233c8-eba9-b042-5578-525270724bec@quadratum-braccas.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-03-15 at 10:53 -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 > > 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 That is correct. The only use I can see in hash partitioning is to put the partitions on different storage devices in order to spread I/O - kind of striping on the database level. Unless you can benefit from that, your queries will become slower. Yours, Laurenz Albe