]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Improve inheritance_planner()'s performance for large inheritance sets.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 22 Jun 2015 22:53:27 +0000 (18:53 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 22 Jun 2015 22:53:27 +0000 (18:53 -0400)
commitd8f9ab776c579cbc886840795cd51fab5a3c2d8a
treef9df85cca4acd36f832552aebcd5b0164e978bc5
parentd1c1e48832f31c1a4d01201a31a60c751ed4895c
Improve inheritance_planner()'s performance for large inheritance sets.

Commit c03ad5602f529787968fa3201b35c119bbc6d782 introduced a planner
performance regression for UPDATE/DELETE on large inheritance sets.
It required copying the append_rel_list (which is of size proportional to
the number of inherited tables) once for each inherited table, thus
resulting in O(N^2) time and memory consumption.  While it's difficult to
avoid that in general, the extra work only has to be done for
append_rel_list entries that actually reference subquery RTEs, which
inheritance-set entries will not.  So we can buy back essentially all of
the loss in cases without subqueries in FROM; and even for those, the added
work is mainly proportional to the number of UNION ALL subqueries.

Back-patch to 9.2, like the previous commit.

Tom Lane and Dean Rasheed, per a complaint from Thomas Munro.
src/backend/optimizer/plan/planner.c