Re: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions - Mailing list pgsql-bugs

From Andrew Gierth
Subject Re: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions
Date
Msg-id 878twtsssp.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions  (shirshegsm@gmail.com)
List pgsql-bugs
>>>>> "shirshegsm" == shirshegsm  <shirshegsm@gmail.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)

pgsql-bugs by date:

Previous
From: shirshegsm@gmail.com
Date:
Subject: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions
Next
From: Tom Lane
Date:
Subject: Re: BUG #14235: inconsistencies with IS NULL / IS NOT NULL