Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQagV-0008Sp-2L for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Jul 2016 13:40:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bQagU-00053e-Lv for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Jul 2016 13:40: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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bQafq-0004JF-M3 for pgsql-bugs@postgresql.org; Fri, 22 Jul 2016 13:39:30 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bQafl-0003Wn-RN for pgsql-bugs@postgresql.org; Fri, 22 Jul 2016 13:39:30 +0000 Received: from localhost ([127.0.0.1]:52632 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1bQafj-000F0S-Sa; Fri, 22 Jul 2016 13:39:23 +0000 From: Andrew Gierth To: shirshegsm@gmail.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions In-Reply-To: <20160722062029.7448.19810@wrigleys.postgresql.org> (shirshegsm@gmail.com's message of "Fri, 22 Jul 2016 06:20:29 +0000") Message-ID: <878twtsssp.fsf@news-spur.riddles.org.uk> References: <20160722062029.7448.19810@wrigleys.postgresql.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Fri, 22 Jul 2016 14:39:23 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org >>>>> "shirshegsm" == shirshegsm writes: shirshegsm> After some discussion on #postgresql @ Freenode (abridged shirshegsm> version: https://paste.fedoraproject.org/393752/16805914/), shirshegsm> it seems that the query planner has O(n^2) complexity for shirshegsm> the number of partitions in a partitioned table. To sum up my part of that discussion: the repeated calls to adjust_appendrel_attrs cause an O(N^2) number of calls to palloc, as query_tree_mutator calls range_table_mutator which does two pallocs per RTE (one for the RTE and one for the listcell). Also none of those get freed, as far as I can tell, so the memory usage is O(N^2) too. -- Andrew (irc:RhodiumToad) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs