postgresql/src/include/commands
Tom Lane 939f0fb676 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:19 -05:00
..
alter.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
async.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
cluster.h Separate multixact freezing parameters from xid's 2014-02-13 19:30:30 -03:00
collationcmds.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
comment.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
conversioncmds.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
copy.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
createas.h Clean up the mess around EXPLAIN and materialized views. 2013-04-12 19:25:31 -04:00
dbcommands.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
defrem.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:32 -05:00
discard.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
event_trigger.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
explain.h Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:19 -05:00
extension.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
lockcmds.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
matview.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
portalcmds.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
prepare.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
proclang.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
schemacmds.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
seclabel.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
sequence.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
tablecmds.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:32 -05:00
tablespace.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
trigger.h Avoid repeated name lookups during table and index DDL. 2014-02-17 09:33:32 -05:00
typecmds.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
user.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
vacuum.h Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats. 2014-10-30 13:03:28 -04:00
variable.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
view.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00