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 1hxFwO-0006VN-ES for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 19:25:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxFwM-0006uE-Vj for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 19:25:10 +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 1hxFwM-0006u6-N9 for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 19:25:10 +0000 Received: from mout.perfora.net ([74.208.4.197]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxFwJ-0004nJ-Hw for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 19:25:10 +0000 Received: from [192.168.1.101] ([98.169.208.73]) by mrelay.perfora.net (mreueus004 [74.208.5.2]) with ESMTPSA (Nemesis) id 1Ma1LU-1hlAc40ZzY-00VutK; Mon, 12 Aug 2019 21:25:00 +0200 Subject: Re: Planner performance in partitions To: Michael Lewis Cc: =?UTF-8?Q?Piotr_W=c5=82odarczyk?= , "pgsql-performance@lists.postgresql.org" References: <5675f9f771f04d9f8b5cffe16f4a4175@EX13MBX02.gb.ad.corp> From: MichaelDBA Message-ID: <458dfc43-b097-29f3-4e0e-857b9c30b427@sqlexec.com> Date: Mon, 12 Aug 2019 15:24:58 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/6.1.18 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D2DD700252F0E55F5787EA27" Content-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eU66aUFVP+ObiIcVvfcQFVOHY= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D2DD700252F0E55F5787EA27 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Queries against tables with a lot of partitions (> 1000) start to incur an increasing planning time duration even with the current version, V11.  V12 purportedly has fixed this problem, allowing thousands of partitioned tables without a heavy planning cost.  Can't seem to find the threads on this topic, but there are out there.  I personally noted a gigantic increase in planning time once I got past 1500 partitioned tables in V11. On another note, hopefully they have fixed runtime partition pruning in V12 since V11 introduced it but some query plans don't use it, so you have to reconstruct some queries to sub queries to make it work correctly. Regards, Michael Vitale Michael Lewis wrote on 8/12/2019 3:05 PM: > "It is also important to consider the overhead of partitioning during > query planning and execution. The query planner is generally able to > handle partition hierarchies with */up to a few hundred partitions > fairly well/*, provided that typical queries allow the query planner > to prune all but a small number of partitions. Planning times become > longer and memory consumption becomes higher as more partitions are > added." (emphasis added) > > --https://www.postgresql.org/docs/current/ddl-partitioning.html --------------D2DD700252F0E55F5787EA27 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Queries against tables with a lot of partitions (> 1000) start to incur an increasing planning time duration even with the current version, V11.  V12 purportedly has fixed this problem, allowing thousands of partitioned tables without a heavy planning cost.  Can't seem to find the threads on this topic, but there are out there.  I personally noted a gigantic increase in planning time once I got past 1500 partitioned tables in V11.

On another note, hopefully they have fixed runtime partition pruning in V12 since V11 introduced it but some query plans don't use it, so you have to reconstruct some queries to sub queries to make it work correctly.

Regards,
Michael Vitale


Michael Lewis wrote on 8/12/2019 3:05 PM:
"It is also important to consider the overhead of partitioning during query planning and execution. The query planner is generally able to handle partition hierarchies with up to a few hundred partitions fairly well, provided that typical queries allow the query planner to prune all but a small number of partitions. Planning times become longer and memory consumption becomes higher as more partitions are added." (emphasis added)

--------------D2DD700252F0E55F5787EA27--