pgsql: Improve inheritance_planner()'s performance for large inheritanc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve inheritance_planner()'s performance for large inheritanc
Date: 2015-06-22 22:53:46
Message-ID: E1Z7Ab4-00024u-NM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e538e510e11a6d3aa2a080f36bc46f1cb537532f

Modified Files
--------------
src/backend/optimizer/plan/planner.c | 89 +++++++++++++++++++++++++++++++---
1 file changed, 83 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2015-06-23 00:41:18 pgsql: pg_rewind: Improve message wording
Previous Message Robert Haas 2015-06-22 18:15:58 pgsql: psql: Add some tab completion for TABLESAMPLE.