Re: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: shirshegsm(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions
Date: 2016-07-22 13:39:23
Message-ID: 878twtsssp.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "shirshegsm" == shirshegsm <shirshegsm(at)gmail(dot)com> 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)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-07-22 20:21:44 Re: BUG #14235: inconsistencies with IS NULL / IS NOT NULL
Previous Message shirshegsm 2016-07-22 06:20:29 BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions