postgresql/src/backend
Tom Lane a5cd70dcbc Improve performance of EXPLAIN with large range tables.
As of 9.3, ruleutils.c goes to some lengths to ensure that table and column
aliases used in its output are unique.  Of course this takes more time than
was required before, which in itself isn't fatal.  However, EXPLAIN was set
up so that recalculation of the unique aliases was repeated for each
subexpression printed in a plan.  That results in O(N^2) time and memory
consumption for large plan trees, which did not happen in older branches.

Fortunately, the expensive work is the same across a whole plan tree,
so there is no need to repeat it; we can do most of the initialization
just once per query and re-use it for each subexpression.  This buys
back most (not all) of the performance loss since 9.2.

We need an extra ExplainState field to hold the precalculated deparse
context.  That's no problem in HEAD, but in the back branches, expanding
sizeof(ExplainState) seems risky because third-party extensions might
have local variables of that struct type.  So, in 9.4 and 9.3, introduce
an auxiliary struct to keep sizeof(ExplainState) the same.  We should
refactor the APIs to avoid such local variables in future, but that's
material for a separate HEAD-only commit.

Per gripe from Alexey Bashtanov.  Back-patch to 9.3 where the issue
was introduced.
2015-01-15 13:18:12 -05:00
..
access Tweak heapam's rmgr desc output slightly 2015-01-12 16:09:16 -03:00
bootstrap Remove some dead IsUnderPostmaster code from bootstrap.c. 2015-01-14 00:37:02 +01:00
catalog Spell the X072 feature correctly, was missing "with". 2015-01-13 16:08:55 +02:00
commands Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:12 -05:00
executor Fix typo in execMain.c 2015-01-09 11:07:35 -05:00
foreign Update copyright for 2015 2015-01-06 11:43:47 -05:00
lib Update copyright for 2015 2015-01-06 11:43:47 -05:00
libpq Update copyright for 2015 2015-01-06 11:43:47 -05:00
main Always set the six locale category environment variables in main(). 2015-01-07 22:34:57 -05:00
nodes Update copyright for 2015 2015-01-06 11:43:47 -05:00
optimizer Update copyright for 2015 2015-01-06 11:43:47 -05:00
parser Fix get_object_address argument type for extension statement 2015-01-12 15:32:48 -03:00
po Translation updates 2014-12-15 00:25:35 -05:00
port Add barriers to the latch code. 2015-01-13 12:58:43 +01:00
postmaster Add a default local latch for use in signal handlers. 2015-01-14 18:45:22 +01:00
regex Update copyright for 2015 2015-01-06 11:43:47 -05:00
replication Add a default local latch for use in signal handlers. 2015-01-14 18:45:22 +01:00
rewrite Update copyright for 2015 2015-01-06 11:43:47 -05:00
snowball Update copyright for 2015 2015-01-06 11:43:47 -05:00
storage Add a default local latch for use in signal handlers. 2015-01-14 18:45:22 +01:00
tcop Add a default local latch for use in signal handlers. 2015-01-14 18:45:22 +01:00
tsearch Update copyright for 2015 2015-01-06 11:43:47 -05:00
utils Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:12 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
nls.mk xlogreader.c: Fix report_invalid_record translatability flag 2015-01-09 12:34:25 -03:00