From: shirshegsm@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14263: Query planner is slow to plan UPDATE on a table with many partitions
Date: Fri, 22 Jul 2016 06:20:29 +0000
Message-ID: <20160722062029.7448.19810@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14263
Logged by: Linas Valiukas
Email address: shirshegsm@gmail.com
PostgreSQL version: 9.3.13
Operating system: Ubuntu 12.04.5 LTS
Description:
Hi there,
We have a partitioned table, "bitly_clicks_total", with 600 partitions, up
to 1m rows in each sub-table. Property constraint_exclusion is
'partition'.
SELECTs on said table work as expected, but UPDATEs spend a lot of time on
query planner phase, even though executing the plan afterwards is very fast,
i.e. see https://paste.fedoraproject.org/393750/16797914/.
Here's a way to replicate the issue on an empty table with 600 partitions
too, so it doesn't depend on the number of rows in the partitioned table:
https://paste.fedoraproject.org/393751/91680241/
After some discussion on #postgresql @ Freenode (abridged version:
https://paste.fedoraproject.org/393752/16805914/), it seems that the query
planner has O(n^2) complexity for the number of partitions in a partitioned
table. Thus, I've been advised to split the table into less partitions, but
I found it unexpected that a sheer number of tables could slow down UPDATEs
like that, so I think that this behaviour could be at very least documented
accordingly.
Regards,
Linas
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: shirshegsm@gmail.com
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>
References: <20160722062029.7448.19810@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox