postgresql/src/backend/commands
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
..
Makefile Row-Level Security Policies (RLS) 2014-09-19 11:18:35 -04:00
aggregatecmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
alter.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
analyze.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
async.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
cluster.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
collationcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
comment.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
constraint.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
conversioncmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
copy.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
createas.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
dbcommands.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
define.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
discard.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
dropcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
event_trigger.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
explain.c Improve performance of EXPLAIN with large range tables. 2015-01-15 13:18:12 -05:00
extension.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
foreigncmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
functioncmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
indexcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
lockcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
matview.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
opclasscmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
operatorcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
policy.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
portalcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
prepare.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
proclang.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
schemacmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
seclabel.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
sequence.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
tablecmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
tablespace.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
trigger.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
tsearchcmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
typecmds.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
user.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
vacuum.c Reject ANALYZE commands during VACUUM FULL or another ANALYZE. 2015-01-07 22:33:58 -05:00
vacuumlazy.c Fix logging of pages skipped due to pins during vacuum. 2015-01-08 12:57:09 +01:00
variable.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
view.c Update copyright for 2015 2015-01-06 11:43:47 -05:00